HOWTO进行类似于那些在设置布局类似于、布局、HOWTO

2023-09-05 05:15:08 作者:别听谣言与xx为敌

我有一个机器人的活动,我需要让用户输入一些信息。该数据适合于有点像preferenceView使用列表preferance元素。我相信,我可以使用preferences接口来获得我所需要的,但它会通过cludgy。有没有办法让这些小部件一样在普通视图?

I have an android Activity where I need to have the user enter some information. The data lends itself to something like a PreferenceView with ListPreferance elements. I am sure that I could use the preferences interfaces to get what I need, but it would by cludgy. Is there a way to get these same widgets in a regular view?

推荐答案

我最近按照类似的方法列出的此处。沸腾,而不是默认的共享preferences下降到提供preference XML到你的preferenceActivity,然后用自己的模型支持它。在这个例子中,他使用一个数据库,但如果你没有后备数据库(或者你不想犯每当设置改变),你可以使用地图为后盾编辑器。

I recently solved this same issue by following a similar approach to the one listed here. It boils down to providing a preference XML to your PreferenceActivity and then backing it with your own Model, instead of the default sharedPreferences. In the example he uses a database but if you don't have a backing database (or you don't want to commit whenever a setting is changed) you can use a Map for backing the Editor.