preferences没有pcated德$ P $方法方法、preferences、pcated

2023-09-13 01:28:05 作者:情场通缉犯

我想(正确地)实行preferences屏幕,但问题是,所有的方法,用来读取XML文件preferences都去precated(或我只是不识别它们)。在开发站点的官方样片code($p$pferenceActivity)采用德precated方法有没有人找到了一种方法来实现preferences屏幕使用XML文件,但没有使用任一方法:?增加preferencesFromResource(INT)或查找preference(CharSequence的)或有方法刚刚被标德pcated没有实施替代尚未$ P $?

I'm trying to (correctly) implement a preferences screen, but the problem is that all the methods used to read preferences from xml files are deprecated (or I just don't recognize them). The official sample code on the dev site (PreferenceActivity) uses deprecated methods. Has anyone found out a way to implement a preferences screen with an xml file but without using either: addPreferencesFromResource(int) or findPreference(CharSequence)? Or have the methods just been marked deprecated without implementing the alternative yet?

编辑:开发Android版2.1

Developing for Android version 2.1

推荐答案

为什么要其去precated,什么是另一种方法是pretty的在文档很好的解释:

Why its deprecated and what is the alternative is pretty well explained in documentation:

这是一个活动,以显示preferences层次用户的基类。此前蜂窝状这个类只允许单套preference的显示;这个功能现在应该在新的preferenceFragment类中找到。如果在旧模式下使用preferenceActivity,文档也适用于德precated这里的API。

This is the base class for an activity to show a hierarchy of preferences to the user. Prior to HONEYCOMB this class only allowed the display of a single set of preference; this functionality should now be found in the new PreferenceFragment class. If you are using PreferenceActivity in its old mode, the documentation there applies to the deprecated APIs here.

在换句话说,如果你想成为蜂窝标准,那么你应该使用$p$pferenceFragment为你的 preferenceActivity 。关于如何使用碎片的详细解释可以在开发指南被发现。

In other words, if you want to be HONEYCOMB compliant, then you should use PreferenceFragment for your PreferenceActivity. A detailed explanation on how to use fragments can be found in dev guide.