나는 내 자신을 알아 냈습니다. 여기 있습니다.
1은 DialogPreference의 XML
<include layout="@layout/activity_header_template" />
의 헤더 템플릿에 대한 다음 줄을 포함 그냥 일반 사용자 정의 대화 템플릿과 같은 사용자 정의 대화 레이아웃을 준비합니다. 진짜 필요 내가
이것은
<?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>
다음 줄은 내 ListPreference의 XML 코드 (단지 암호를 확인하기 위해) 암호 (1) 및 암호 2. 두 개의 입력을 원하는, 내가 DialogPreference을 사용자 정의 할 수있다 매우 중요의 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