<PreferenceCategory android:title="Login email">
<PreferenceScreen
android:key="display_email"
android:title="test email"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/server_settings_title">
<PreferenceScreen
android:key="Server_Select"
android:summary="@string/server_select_summary"
android:title="@string/server_pref"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/settings_title">
<SwitchPreference
android:id="@+id/enter_send"
android:defaultValue="true"
android:key="@string/settings_enterPreference_key"
android:summary="@string/settings_enterPreference_summary"
android:title="@string/settings_enterPreference_label" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/settings_mic">
<SwitchPreference
android:id="@+id/mic_input"
android:defaultValue="true"
android:key="@string/setting_mic_key"
android:summary="@string/settings_micPreference_summary"
android:title="@string/setting_mic_input" />
<SwitchPreference
android:id="@+id/hotword_detection"
android:defaultValue="false"
android:key="@string/setting_hotword_key"
android:summary="@string/settings_hotwordPreference_summary"
android:title="@string/setting_hotword_detection" />
</PreferenceCategory>
我想更改类别而不是屏幕的文本颜色。我已经提到了许多与此有关的文档和博客文章,但都是徒劳的。这是大型代码库的一部分,因此我要小心
答案 0 :(得分:0)
创建一个扩展PreferenceCategory的类。
C:\Program File\IIS Express
然后用xml中的自定义类名称替换PreferenceCategory,像这样:
public class CustomPreferenceCategory extends PreferenceCategory {
@TargetApi(21)
public CustomPreferenceCategory(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
this.init(context, attrs);
}
public CustomPreferenceCategory(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.init(context, attrs);
}
public CustomPreferenceCategory(Context context, AttributeSet attrs) {
super(context, attrs);
this.init(context, attrs);
}
public CustomPreferenceCategory(Context context) {
super(context);
this.init(context, (AttributeSet)null);
}
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
TextView title = (TextView)holder.itemView;
title.setTextColor(Color.BLACK);
}
private void init(Context context, AttributeSet attrs) {
this.setLayoutResource(R.layout.preference_category);
}