使用图标的Andr​​oid preferences [英] Using icons in Android preferences

查看:84
本文介绍了使用图标的Andr​​oid preferences的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我的一些preferences有图标,如设置应用程序。

I would like some of my preferences to have icons, like the Settings app.

我想这样做,将复制所有相关的code和资源设置应用程序的一种方式,但它似乎是大材小用了几个图标。

I guess one way of doing this would be to copy all the relevant code and resources from the Settings app, but it seems like overkill for a couple of icons.

此外,我不喜欢有重复的code和资源在各个项目中,需要设置图标的想法。

Also I don't like the idea of having to duplicate the code and resources in each project that requires settings icons.

有没有人解决了这个已经有一个简单的资源或无的方式?

Has anyone solved this already with a simpler or resource-free approach?

推荐答案

Settings(设置)应用程序使用私人定制 preferenceScreen 子类有图标 - 图标preferenceScreen 。这是51行code,包括评论,虽然它也需要一些自定义属性。最简单的方法是克隆了这一切到您的项目,即使你不喜欢这一点。

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.

源$ C ​​$ C

这篇关于使用图标的Andr​​oid preferences的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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