首选项活动列表首选项

发布于 2024-12-29 20:39:06 字数 478 浏览 8 评论 0原文

我正在为我的 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 技术交流群。

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

发布评论

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

评论(1

画骨成沙 2025-01-05 20:39:06

首先,您需要一个 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 an Intent based on the android:entryValues that is selected. Of course, it really depends on what exactly you want it to do.

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