获得preferenceManager德precated [英] getPreferenceManager deprecated

查看:429
本文介绍了获得preferenceManager德precated的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Android动态壁纸。我有墙纸的一部分工作,我试图设置添加到它。在LiveWallpaperSettings我有这样的:

I am making a live wallpaper for Android. I have the wall paper part working and am trying to add settings to it. In LiveWallpaperSettings I have this:

@Override
protected void onCreate(Bundle icicle)
{
    super.onCreate(icicle);
    getPreferenceManager().setSharedPreferencesName(LiveWallpaperService.SHARED_PREFS_NAME);
    addPreferencesFromResource(R.string.livewallpaper_settings);
    getPreferenceManager().getSharedPreferences()
            .registerOnSharedPreferenceChangeListener(this);
}

编译器说,的get preferenceManager()添加preferencesFromResource()是德precated。我应该是用呢?

The compiler says that getPreferenceManager() and addPreferencesFromResource() are deprecated. What should I be using instead?

这些方法是从 preferenceActivity

:基于评论到目前为止,我显然是在用一个过时的方法屈指可数。可有人点code的使用LiveWallpaper preferenceFragments当代的例子吗?

: Based on the handful of comments thus far, I apparently am using an antiquated approach. Can someone point to a contemporary example of code for LiveWallpaper using PreferenceFragments?

https://github.com/falsedmitri/LiveWallpaperTest.git

推荐答案

从的为preferenceActivity文档

要蜂窝状这个类只允许单套preference的显示在此之前,这个功能现在应该在新的preferenceFragment类中找到。如果你正在使用preferenceActivity在旧模式下,文件也适用于德$ P $这里pcated的API。

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.

所以,你可以切换到使用片段或者你可以忽略这些警告。 (记者了解到,德precated方法将从API有一天消失......)

So you can either switch to using Fragments or you can ignore these warnings. (Understand that deprecated methods will disappear from the API someday...)

可有人点code的使用LiveWallpaper preferenceFragments当代的例子吗?

Can someone point to a contemporary example of code for LiveWallpaper using PreferenceFragments?

有没有preferenceActivities和preferenceFragments使用的方法之间的主要区别,一般来说切换到片段是大的变化。但 preferenceFragment 有一个例子,你看,你仍然可以使用像添加方法preferencesFromResource()在它的现代形式。

There isn't a major difference between the methods used in PreferenceActivities and PreferenceFragments, switching to Fragments in general is the big change. But PreferenceFragment has an example and you see you can still use methods like addPreferencesFromResource() in it's modern form.

这篇关于获得preferenceManager德precated的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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