今では色々サンプルが転がってますが、完結してなくて結局いくつかを見て回ることになるので記録を残しておこうかなと。
/res/xml フォルダを作成し、setting.xml(ファイル名は適宜)を作成
2 | < preferencecategory android:title = "@string/setting_title" > |
3 | < listpreference android:defaultvalue = "1" android:dialogtitle = "@string/select_choice_dlg_title" android:entries = "@array/select_labels" android:entryvalues = "@array/select_values" android:key = "select_choice" android:summary = "@string/select_choice_summary" android:title = "@string/select_choice_title" > |
strings.xml に以下のように記述
01 | < string name = "setting_title" >設定string > |
03 | < string name = "select_choice_dlg_title" >選択string > |
04 | < string name = "select_choice_summary" >設定を選びます。string > |
05 | < string name = "select_choice_title" >以下から選んでください。string > |
07 | < string-array name = "select_labels" > |
11 | < string-array name = "select_values" > |
javaサンプル
1 | public class Main extends PreferenceActivity { |
4 | public void onCreate(Bundle savedInstanceState) { |
5 | super .onCreate(savedInstanceState); |
7 | addPreferencesFromResource(R.xml.setting); |
0 件のコメント:
コメントを投稿