我有一个 DialogPreference。我想设置它的对话框标题(setTitle()),但它不起作用。
我的代码:
public class RestoreDefaultApperanceDialogPreference extends DialogPreference {
Dialog dialog;
public RestoreDefaultApperanceDialogPreference(Context context,
AttributeSet attrs) {
super(context, attrs);
dialog = getDialog();
//dialog.setTitle("Restore default colors?"); //<- NOT WORKING!
// TODO Auto-generated constructor stub
}
public RestoreDefaultApperanceDialogPreference(Context context,
AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
}
XML 文件(偏好类别):
<PreferenceCategory android:title="Appearance settings">
<com.example.dictionary.ColorSelectPreference
android:key="onlineRecognitionColor"
android:title="Online recognision results color"
android:summary="Customize color of online recognition results."
/>
<com.example.dictionary.ColorSelectPreference
android:key="offlineRecognitionColor"
android:title="Offline recognition results color"
android:summary="Customize color of offline recognition results."
/>
<com.example.dictionary.RestoreDefaultApperanceDialogPreference
android:key="restoreDefaultApperance"
android:title="Restore default apperance"
android:summary="Choose this option to restore default apperance settings."
/>
</PreferenceCategory>
如何设置此对话框的标题