我正在制作一个扩展 PreferenceActivity 的应用,我想为每个 Preference 添加一个图标。
我读到了一个类似的问题,这是更有名气的答案:
CommonsWare 说:
The Settings application uses a private custom PreferenceScreen subclass to have the icon -- IconPreferenceScreen. It is 51 lines of code, including the comments, though it also requires some custom attributes. The simplest option is to clone all of that into your project, even though you do not like that.
但我不能让它工作。现在我将 IconPreferenceScreen 类克隆到我的项目中。而且我不知道在这之后我要做什么。我正在尝试制作一个新的 IconPreferenceScreen 我无法让它工作..
IconPreferenceScreen test = new IconPreferenceScreen();
test.setIcon(icon);
最佳答案
今天你可以使用自 API 11 起可用的 android:icon
attr :)
关于android - 如何将图标添加到首选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5765186/