I would like to create a simple (yes/no) dialog preference, I followed the the answers in this post - creating a DialogPreference from XML
But I get an error saying
java.lang.IllegalArgumentException: Tried to display dialog for unknown preference type. Did you forget to override onDisplayPreferenceDialog()?
at android.support.v7.preference.PreferenceFragmentCompat.onDisplayPreferenceDialog(PreferenceFragmentCompat.java:647)
at android.support.v7.preference.PreferenceManager.showDialog(PreferenceManager.java:553)
at android.support.v7.preference.DialogPreference.onClick(DialogPreference.java:262)
at android.support.v7.preference.Preference.performClick(Preference.java:1115)
at android.support.v7.preference.Preference.performClick(Preference.java:1100)
at android.support.v7.preference.Preference$1.onClick(Preference.java:170)
at android.view.View.performClick(View.java:4756)
at android.view.View$PerformClick.run(View.java:19749)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
My XML
<android.support.v7.preference.PreferenceCategory android:title="History & privacy">
<com.game.prefs.views.DialogPref
android:key="pref_clear_search"
android:title="Reset Quests"
android:summary="Reset all quest-progress."
android:dialogMessage="Are you sure you wish to reset your quest progress? This action cannot be undone!"
android:positiveButtonText="Clear Quests"
android:negativeButtonText="Cancel"/>
</android.support.v7.preference.PreferenceCategory>
And my JAVA code
public class DialogPref extends DialogPreference {
public DialogPref(Context context, AttributeSet attrs) {
super(context, attrs);
}
}
What am I doing wrong ?