출처 : http://viralpatel.net/blogs/android-preferences-activity-example/
AndroidManifest.xml
<activity android:name=".UserSettingActivity"/>
MainActivity
Intent i = new Intent(this, UserSettingActivity.class); startActivityForResult(i, RESULT_SETTINGS); @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case RESULT_SETTINGS: // doSomething break; } }
UserSettingActivity
public class UserSettingActivity extends PreferenceActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // To support API Level 10 or lower addPreferencesFromResource(R.xml.settings); } }
res/xml/settings.xml
<?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > <PreferenceCategory android:title="@string/pref_user_profile" > <EditTextPreference android:title="@string/pref_user_name" android:summary="@string/pref_user_name_summary" android:key="prefUsername"/> </PreferenceCategory> <PreferenceCategory android:title="@string/pref_update_setting" > <CheckBoxPreference android:defaultValue="false" android:key="prefSendReport" android:summary="@string/pref_send_report_summary" android:title="@string/pref_send_report" > </CheckBoxPreference> <ListPreference android:key="prefSyncFrequency" android:entries="@array/syncFrequency" android:summary="@string/pref_sync_frequency_summary" android:entryValues="@array/syncFrequencyValues" android:title="@string/pref_sync_frequency" /> </PreferenceCategory> </PreferenceScreen>
댓글 없음:
댓글 쓰기