个人preferences在一个ListView每个项目? [英] Individual Preferences for each item in a ListView?

查看:129
本文介绍了个人preferences在一个ListView每个项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建我的第一个Android应用(或试图反正)和我有一个问题,我似乎无法找到答案。

I'm creating my first android app (or attempting to anyway) and i have a question i can't seem to find the answer to.

我想允许用户输入一组独立的preferences为在列表视图中的每个项目。我有preferenceScreen工作,但它保持了相同preferences为每个项目(即改变1项结果改变所有其他人也)。

I would like to allow users to enter a separate set of preferences for each item in a list view. I have the PreferenceScreen working, but it maintains the same preferences for every item (i.e. changing 1 item results in changes to all others as well).

要给出一个更详细的例子:
说我有车的列表:
*汽车1
* 2车
*等等...

To give a more detailed example: Say i have a list of cars: * Car 1 * Car 2 * Etc...

我想是不是有在全球范围内存储的条目能够点击汽车1,并获得了preferencesScreen指定制作只是那车,示范单位,颜色,整个应用程序。

I would like to be able to click on "Car 1" and get a PreferencesScreen to specify "Make", "Model", "Color" for just that car, instead of having those entries stored globally for the whole app.

这可能吗?

感谢您的帮助!

//ñ

推荐答案

解决它!

有关的任​​何疑惑,解决的办法是,你必须调用

For any wondering, the solution is that you must call

的get preferenceManager()。setShared preferenceName(值)独特的项目的值要修改preferences对(在我的情况,我用的ListView 位置)调用之前添加preferencesFromResource

getPreferenceManager().setSharedPreferenceName(value) with a value unique to the item you'd like to modify the preferences for (in my case, i used the ListView position) prior to calling addPreferencesFromResource.

这篇关于个人preferences在一个ListView每个项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆