如何改变preference类文本颜色的Android? [英] How to change text color of preference category in Android?
本文介绍了如何改变preference类文本颜色的Android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
的文字颜色属性不工作。这里是我的XML:
The textColor attribute isn't working. Here's my XML:
<PreferenceCategory
android:title="Title"
android:textColor="#00FF00">
任何想法?
推荐答案
使用此定制preferenceCategory类:
use this customize PreferenceCategory class :
public class MyPreferenceCategory extends PreferenceCategory {
public MyPreferenceCategory(Context context) {
super(context);
}
public MyPreferenceCategory(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyPreferenceCategory(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
TextView titleView = (TextView) view.findViewById(android.R.id.title);
titleView.setTextColor(Color.RED);
}
}
和你的pref.xml文件补充一点:
and add this at your Pref.xml file :
<ali.UI.Customize.MyPreferenceCategory android:title="@string/pref_server" />
这篇关于如何改变preference类文本颜色的Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文