Android: subclassing DialogPreference

2019-08-03 02:45发布

问题:

I am trying to create custom dialog preference that will hold radio group with two radio buttons and one edittext. If I write something like

<DialogPreference android:title="preftitle" android:dialogLayout="@layout/preflayout" android:summary="pref summary" android:key="prefkey" android:defaultValue="defaultValue" />
the application breaks when trying to create PreferenceActivity that holds this dialog preference.

I guess I have to subclass DialogPreference and put that subclass as xml element. But I don't know what methods should I override and how.

Could anyone help?

回答1:

Take a look here,

creating a DialogPreference from XML

You are correct, you need to subclass DialogPreference.