开发者

SeekBar value gets Reset in preference automatically if I choose any other control in the preference

开发者 https://www.devze.com 2023-01-31 09:52 出处:网络
I have added a SeekBar control to the preference by java code. It\'s got added and shown up in the preference. I also added a EditTextPreference and a checkbox to the preference. Now I dragge开发者_如

I have added a SeekBar control to the preference by java code. It's got added and shown up in the preference. I also added a EditTextPreference and a checkbox to the preference. Now I dragge开发者_如何学JAVAd up the seekbar to some value. After this if I select checkbox the seekbar gets reset to initial value ( I meant to say the selected seekbar value not staying ...it is going back...). Do you please guide me what went wrong?


What I think you may need to do is implement OnSeekBarChanged and add an onProgressChanged function to your code, then have it reset the seekbar preference to the current value. Since you didn't include any code, nor did you specify, I don't know if you ever tried to reset the value. If you didn't, it makes sense that the seekbar would set itself back to the preference value. Hope that helps a bit.


I found where the problem is. Actually OnCreateView method of the custom preference gets called whenever the checkboxpreference or edittextpreference been edited. I am just resetting the SeekBar value from sharedpreferences saved values in onCreateView method of my custom preference. That fixed my problem. And thanks to all for there replies.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号