
主活动从arrays.xml读取其配置,如下所示
<?xml version="1.0" enCoding="utf-8"?><resources> <string-array name="home_buttons_text"> <item>@string/Title_1</item> </string-array> <array name="home_buttons_icon"> <item>@drawable/Google</item> </array> <string-array name="home_buttons_url"> <item>http://www.Google.com</item> </string-array> <array name="themes"> <item>@style/my_theme</item> </array></resources>
通过这种方式添加一个新图标,我只需在这里添加新行.
所以在“主题”中我有主题的名字.我如何加载和应用名称引用的主题?
对于我用过的图标
TypedArray mItemsIcons = resources.obtainTypedArray(R.array.home_buttons_icon);TypedArray mthemes = resources.obtainTypedArray(R.array.themes);...mItemsIcons.getDrawable(position);...
但我不知道如何获得主题.
我测试过了
int theme = mthemes.getResourceID(position);settheme(theme);
但它不起作用.
点击此处了解详情:http://developer.android.com/guide/topics/resources/more-resources.html#TypedArray
解决方法 你可以在调用setContentVIEw(…)和super.oncreate()之前使用settheme(..)它应该可以正常工作 @H_403_0@ 总结以上是内存溢出为你收集整理的android – 动态更改活动主题全部内容,希望文章能够帮你解决android – 动态更改活动主题所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)