作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在寻找一种方法,在用户在列表首选项中选择一个选项后,在首选项中显示第二个列表
例如:用户从列表中选择“发送短信至”选项,然后出现第二个列表,用户可以选择联系人。
目前,我正在尝试从我的首选项 Activity 中放置一个 onSharedPreferenceChanged 方法,并在选择后显示一个包含联系人的警报对话框,但我认为还有另一种方法...但我还没有找到它互联网...
有人知道这是怎么可能的吗?
谢谢
最佳答案
在您的 PreferenceActivity
中放置一个如下所示的方法,用于监听何时单击该特定键。
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
//Make sure the item changed was the list_preference
if(key.equals("list_preference")) {
String value = sharedPreferences.getString(key, "Nothing");
if(value.equals("Send_sms")) {
//launch AlertDialog with list or launch new preference
}
}
}
关于java - Android PreferenceList,选择后的子列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9431484/
我正在寻找一种方法,在用户在列表首选项中选择一个选项后,在首选项中显示第二个列表 例如:用户从列表中选择“发送短信至”选项,然后出现第二个列表,用户可以选择联系人。 目前,我正在尝试从我的首选项 Ac
我是一名优秀的程序员,十分优秀!