CustomPreferenceCategory 无法转换为 android.preference.GenericInflater$Parent

CustomPreferenceCategory cannot be cast to android.preference.GenericInflater$Parent

我做了 CustomPreference 并且它与 PreferenceCategory 配合得很好,但是 CustomPreferenceCategory 有一个问题 uk.co.bla.bla.customwidget.viewgroup.CustomPreferenceCategory 无法转换为 android.preference.GenericInflater$Parent

CustomPreferenceCategory.class

public class CustomPreferenceCategory extends PreferenceCategory {
private TextView txt;
public CustomPreferenceCategory(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.setWidgetLayoutResource(R.layout.preference_category_title);
}


@Override
protected void onBindView(View view) {
    super.onBindView(view);
    txt = (TextView) view.findViewById(R.id.text_view_preference_category_title);
}

public void setText(String text, int color) {
    txt.setText(text);
    txt.setTextColor(color);
}
}

preference_category_title

<android.support.percent.PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/grey_231"
>
<TextView
    android:id="@+id/text_view_preference_category_title"
    android:layout_width="wrap_content"
    android:layout_height="32.5dp"
    android:text="@string/profile_preference"
    android:textSize="14dp"
    android:gravity="center"
    app:layout_marginLeftPercent="3.5%"
    android:textColor="@color/charcoalGrey_30"

    />   
    </android.support.percent.PercentRelativeLayout>

preference.xml

<uk.co.bla.bla.customwidget.viewgroup.CustomPreferenceCategory
    android:name="uk.co.bla.bla.customwidget.viewgroup.CustomPreferenceCategory"
    android:key="@string/profile_preference"
    android:layout="@layout/preference_category_title">

    <uk.co.bla.bla.customwidget.viewgroup.CustomPreferenceButton
        android:name="uk.co.bla.bla.customwidget.viewgroup.CustomPreferenceButton"
        android:layout="@layout/preference_button"
        android:key="@string/edit_profil_button_preference"/>

    <uk.co.bla.bla.customwidget.viewgroup.CustomPreferenceButton
        android:key="@string/change_password_preference"
        android:layout="@layout/preference_button"/>
  </uk.co.bla.bla.customwidget.viewgroup.CustomPreferenceCategory>

解决方案:使缓存无效/重新启动