如果我在首选项中选择任何其他控件,SeekBar 值会自动在首选项中重置

发布于 2024-10-08 18:47:04 字数 172 浏览 0 评论 0原文

我已经通过java代码将SeekBar控件添加到首选项中。它已添加并显示在首选项中。我还在首选项中添加了 EditTextPreference 和复选框。现在我将搜索栏拖动到某个值。在此之后,如果我选择复选框,则搜索栏将重置为初始值(我的意思是说所选搜索栏值不会保留......它会返回......)。 请您指导我出了什么问题吗?

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 dragged 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

拔了角的鹿 2024-10-15 18:47:04

我认为您可能需要做的是实现 OnSeekBarChanged 并将 onProgressChanged 函数添加到您的代码中,然后将其将搜索栏首选项重置为当前值。由于您没有包含任何代码,也没有指定,我不知道您是否尝试过重置该值。如果您没有这样做,则搜索栏会将自身设置回首选项值是有道理的。希望能有所帮助。

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.

自此以后,行同陌路 2024-10-15 18:47:04

我发现问题出在哪里了。实际上,每当编辑 checkboxpreference 或 edittextpreference 时,都会调用自定义首选项的 OnCreateView 方法。我只是从自定义首选项的 onCreateView 方法中保存的共享首选项中重置 SeekBar 值。这解决了我的问题。感谢大家的回复。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文