Androidアプリ入門 No.48 PreferencesActivityのPreferenceCategory
PreferencesActivity
PreferenceCategory
PreferenceCategoryはPreferenceをカテゴリごとにまとめるものである。実例を見るのが早いため実例で確認する。preferences.xmlは以下にする。
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceCategory android:key="category2" android:title="基本"> <CheckBoxPreference android:key="check" android:title="チェックボックス" android:summary="チェックすると状態が変わります" android:summaryOn="チェックされています。" android:summaryOff="チェックされていません。" /> <RingtonePreference android:key="ringtone" android:ringtoneType="notification" android:showDefault="true" android:showSilent="true" android:title="着信音の選択" android:summary="選択してください" /> </PreferenceCategory> <PreferenceCategory android:key="category2" android:title="ダイアログ"> <EditTextPreference android:key="edit" android:dialogIcon="@drawable/icon" android:dialogTitle="文字を入力してください" android:dialogMessage="それでもやるんですか?" android:positiveButtonText="はい!" android:negativeButtonText="いいえ" android:title="テキスト入力" android:summary="テキストを設定します。" /> <ListPreference android:key="list" android:dialogTitle="選択してください" android:entries="@array/aiueoEntries" android:entryValues="@array/aiueoEntryValues" android:title="何か選択してください" android:summary="ひらがなの選択" /> </PreferenceCategory> </PreferenceScreen>