首选项活动列表首选项
我正在为我的 Android 应用程序编写一个 PreferenceActivity
。我对 ListPreference
有疑问。
如何制作一个在选择第一个、第二个或第三个字符串时执行操作的ListPreference
? XML 看起来像这样:
<ListPreference
android:defaultValue="1000"
android:dependency="perform_updates"
android:entries="@array/Select_Shoe_Country"
android:key="updates_interval"
android:summary="Select Shoe"
android:title="Example1" /> `
I am writing a PreferenceActivity
for my Android app. I have question about ListPreference
.
How can I make aListPreference
that does an action if the 1st, 2nd, or 3rd string is selected? The XML looks like this:
<ListPreference
android:defaultValue="1000"
android:dependency="perform_updates"
android:entries="@array/Select_Shoe_Country"
android:key="updates_interval"
android:summary="Select Shoe"
android:title="Example1" /> `
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您需要一个 android:entryValues 数组,以便系统知道每个用户选项的含义。现在,要直接回答您的问题,最简单的方法可能是根据所选的
android:entryValues
启动Intent
。当然,这实际上取决于您到底想要它做什么。First of all, you need an
android:entryValues
array so that the system knows what each of the user's options means. Now, to directly answer your question, it may be easiest to launch anIntent
based on theandroid:entryValues
that is selected. Of course, it really depends on what exactly you want it to do.