[안드로이드] 환경설정(Preference) 다루기 -1

1. XML 파일로Preference Map 설정

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
   <CheckBoxPreference
      android:key="@string/setting_update"
      android:title="@string/pref1_title"
      android:summary="@string/pref1_summary"
      android:defaultValue="true" />
   <CheckBoxPreference
      android:key="@string/setting_movie"
      android:title="@string/pref2_title"
      android:summary="@string/pref2_summary"
      android:defaultValue="true" />
   <CheckBoxPreference
      android:key="@string/setting_wifi"
      android:title="@string/pref3_title"
      android:summary="@string/pref3_summary"
      android:defaultValue="true" />
</PreferenceScreen>

2. Activity Class 생성

public class Settings extends PreferenceActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       addPreferencesFromResource(R.xml.settings);
    }
}

3. Manifest.xml 에 액티비티 등록

<activity android:name="Settings"/>

덧글

댓글 입력 영역