Activity_main.xml
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" >
<EditTextPreference
android:defaultValue="19"
android:key="age"
android:summary="몇 살 입니까"
android:title="나이" />
<CheckBoxPreference
android:key="male"
android:title="성별"
android:summary="남자면 체크"
android:defaultValue="true"/>
</PreferenceScreen>
MainActivity.java
package com.example.sharedpreferenceex02;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
'Android' 카테고리의 다른 글
Preference (0) | 2013.04.04 |
---|---|
액티비티(Activity) - 액티비티간의 통신 (0) | 2013.04.03 |
액티비티(activity) - (0) | 2013.04.03 |
대화상자 - 커스텀대화상자 (0) | 2013.04.02 |
대화상자 - MultiChoiceItems (0) | 2013.04.02 |