Я понял себя. Ну вот.
первых включают следующую строку для шаблона заголовка в DialogPreference XML
<include layout="@layout/activity_header_template" />
и подготовить собственный макет диалога на заказ так же, как нормальный диалоговый шаблон. Реальная потребность в том, что я хочу, чтобы настроить DialogPreference, я хочу два входа для пароля 1 и 2. Пароль (только для подтверждения пароля)
Это мой ListPreference код XML
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/preference_header_encryption">
<CheckBoxPreference
android:key="prefkey_use_passcode"
android:title="@string/preference_name_set_passcode"
android:summary="@string/preference_summary_set_passcode" />
<!-- This is how you need to attach CustomDialogPrefernce, by using the class name -->
<!-- Please ignore title here. Title will come from DialogPreference Constructor -->
<com.nerds.notes.SettPassword
android:key="prefkey_set_passcode"
android:summary="@string/preference_app_protection"
android:dialogMessage="@string/action_delete"
android:positiveButtonText="@string/passcode_ok_button_text"
android:negativeButtonText="@string/passcode_cancel_button_text"
android:dependency="prefkey_use_passcode" />
<CheckBoxPreference
android:key="prefkey_app_protection"
android:title="@string/preference_app_protection"
android:summary="@string/preference_summary_app_protection"
android:dependency="prefkey_use_passcode" />
</PreferenceCategory>
</PreferenceScreen>
Эти линии очень важно, DialogPreference Конструктор
public SettPassword(Context context, AttributeSet attrs) {
super(context, attrs);
setPersistent(false);
setTitle(R.string.preference_name_set_passcode); // This will override ListPreference Title
setDialogLayoutResource(R.layout.passcode_set_dialog_template);
}
следующие строки должны быть закодированы в ListPreference OnCreate метод, чтобы иметь имя пользовательских предпочтений файла
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PreferenceManager manager = getPreferenceManager();
manager.setSharedPreferencesName("Your Preference File Name");
manager.setSharedPreferencesMode(MODE_PRIVATE);
addPreferencesFromResource(R.xml.settings); // ListPreference XML file from XML Folder
}
Некоторые методы, которые я использовал, амортизируются – Kirk