个人preferences在一个ListView每个项目?

编程入门 行业动态 更新时间:2024-10-10 07:23:02
本文介绍了个人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每个项目?

本文发布于:2023-06-11 03:29:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/625706.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:项目   preferences   ListView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!