我使用了这个问题的答案:Android CheckBoxPreference title color 但当我部署到我的应用程序时,我点击"帐户设置" section =>设置已停止 这里有什么问题?
答案 0 :(得分:0)
这是我的自定义CheckBoxPreference
package vn.com.myapp.view;
import android.content.Context;
import android.graphics.Color;
import android.preference.CheckBoxPreference;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;
/**
* Created by anubis on 5/16/15.
*/
public class MyCheckBoxPreferences extends CheckBoxPreference {
public MyCheckBoxPreferences(Context context) {
super(context);
}
public MyCheckBoxPreferences(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyCheckBoxPreferences(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
TextView title = (TextView) view.findViewById(android.R.id.title);
title.setTextColor(Color.BLACK);
}
}

使用它
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="Options" />
<vn.com.myapp.view.MyCheckBoxPreferences
android:checked="true"
android:clickable="false"
android:defaultValue="true"
android:focusable="false"
android:key="contactSync"
android:summary="Sum1"
android:textColorHighlight="@color/textColorSecondary"
android:title="tit1" />
<vn.com.myapp.view.MyCheckBoxPreferences
android:editable="false"
android:checked="true"
android:clickable="false"
android:defaultValue="true"
android:focusable="false"
android:key="smsSync"
android:summary="Sum2"
android:textColorHighlight="@color/textColorSecondary"
android:title="tit2" />
<vn.com.myapp.view.MyCheckBoxPreferences
android:checked="true"
android:clickable="false"
android:defaultValue="true"
android:focusable="false"
android:key="callLogSync"
android:summary="Sum3"
android:textColorHighlight="@color/textColorSecondary"
android:title="tit3" />
</PreferenceScreen>
&#13;