如何动态创建一个Android preference? [英] How can I dynamically create an Android Preference?

查看:912
本文介绍了如何动态创建一个Android preference?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个样机是低于或许可以解释胜于言。从本质上讲,我想通过用户动态排除,项目可以添加的列表/,并且每个项目都有可配置的设置画面。

A mockup is below that probably explains better than words. Essentially, I want a list where items can be added/removed dynamically by the user, and each item has configurable settings screen.

因此​​,有两个关键的位置:

So there are two keys here:

  1. 添加到主preferences屏幕
  2. 在启动一个 activityForResult当一个产品pssed $ P $。本次活动将展示 另一个preferences视图(滑块,复选框,等等),用户 可以操纵这些然后返回新的值被存储在 的数据结构。
  1. Adding to the main preferences screen
  2. Starting an activityForResult when an item is pressed. This activity will show another preferences view (sliders, checkboxes, etc) where the user can manipulate these and then return the new values to be stored in a data structure.

图片:

Image:

推荐答案

其实动态创建preference屏幕很容易。您可以在code(搜索 preferenceFrom code.java 的API演示示例应用程序),或者通过扩展XML文件,你可以这样做写(<$ C C $> preferencesFromXml.java )。这是怎么回事是很难就要到了一个合理的UI和后端存储用户撰写和存储这些动态preference集合。

Actually creating the preference screens dynamically is easy. You can do it in code (search the API Demos sample app for PreferenceFromCode.java) or by expanding an XML file that you can write (PreferencesFromXml.java). What's going to be hard is coming up with a sensible UI and storage back-end for the user to compose and store these dynamic preference collections.

这篇关于如何动态创建一个Android preference?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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