用它代替&QUOT什么;增加preferencesFromResource"在preferenceActivity?用它、QUOT、preferenceActivity、preference

2023-09-11 12:23:10 作者:25.看我电不死你

我只注意到一个事实,即该方法添加preferencesFromResource(INT preferencesResId)标记德precated 在Android的文件(Reference进入)。

I just noticed the fact that the method addPreferencesFromResource(int preferencesResId) is marked deprecated in Android's documentation (Reference Entry).

不幸的是没有替代方法,在方法的描述中提供。

Unfortunately no alternative method is provided in the method's description.

应该使用以连接preferenceScreen.xml到匹配preferenceActivity哪种方法?

Which method should be used instead in order to connect a preferenceScreen.xml to the matching PreferenceActivity?

非常感谢你的帮助。

推荐答案

没有替代方法,在方法的描述中提供,因为preferred方法(如API级别11)是实例$p$pferenceFragment对象从资源文件加载preferences。见样品code在这里:$p$pferenceActivity

No alternative method is provided in the method's description because the preferred approach (as of API level 11) is to instantiate PreferenceFragment objects to load your preferences from a resource file. See the sample code here: PreferenceActivity