有没有办法显示 PreferenceActivity 的当前设置?
我觉得我一定错过了一些东西,但我只是不明白它是什么......我有一个 PreferenceActivity
,其中包含一堆各种首选项(有些是列表,有些只是文本字段)一切都工作正常,但除非我明确地将每个项目的值写入摘要(这显然不是用于此目的),否则我看不到这些项目如何(或在哪里)显示它们当前设置的内容。当我单击它们时,各种视图都会显示正确的设置,但这显然不是意图。
我是否必须创建自己的某种自定义列表项,其中包含一个显示每个元素当前填充值的字段?
I feel like I must be missing something, but I just don't see what it is... I have a PreferenceActivity
with a bunch of various preferences (some are lists, some are just text fields) and it all works fine, but unless I explicitly write each item's value to the summary (which is obviously not intended for this purpose) I don't see how (or where) the items display what they are currently set to. When I click on them the various views show up with the correct settings, but that's clearly not the intention.
Do I have to create my own custom List item of some sort that has a field that displays the currently populated value of each element?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不幸的是,默认的 PreferencesActivity 不显示这些值:如果您想让所有首选项一目了然地显示,那么您所做的确实是正确的方法。
Unfortunately the default PreferencesActivity doesn't display the values: what you're doing is really the way to go if you care to have all the preferences displayed at a glance.
如果您仍然想继续编程方向,请查看此线程: 如何在首选项摘要中显示 Android 首选项的当前值?
那里有一切。
If you still want to go down the programming direction then look at this thread: How do I display the current value of an Android Preference in the Preference summary?
Has everything there.
创建另一个首选项字段:摘要。
每当更新首选项字段或显示首选项屏幕时更新它。
用户将能够“更新”摘要值,但每当他/她输入首选项时,都会显示正确的值。
Create another preference field: summary.
Update it whenever a preference field is updated, or when displaying the preferences screen.
The user will be able to "update" the summary value, but whenever he/she enters preferences, the correct value will be displayed.
对于
ListPreferences
,这是内置的,您可以使用对于
EditTextPreferences
,您可以轻松创建您自己的类:For
ListPreferences
, this is built-in and you can useFor
EditTextPreferences
, you can easily create your own class: