Java tutorial
package com.idevity.card.read; import com.idevity.card.service.R; import android.os.Bundle; import android.preference.PreferenceActivity; import android.preference.PreferenceFragment; import android.view.MenuItem; import android.support.v4.app.NavUtils; /****************************************************************************** * The following code belongs to IDevity and is provided though commercial * license or by acceptance of an NDA only. * * $Id: SettingsActivity.java 196 2013-07-15 15:12:55Z tejohnson $ * * A {@link PreferenceActivity} that presents a set of application settings. On * handset devices, settings are presented as a single list. On tablets, * settings are split by category, with category headers shown to the left of * the list of settings. * <p> * See <a href="http://developer.android.com/design/patterns/settings.html"> * Android Design: Settings</a> for design guidelines and the <a * href="http://developer.android.com/guide/topics/ui/settings.html">Settings * API Guide</a> for more information on developing a Settings UI. * * @author Matthew Ambs (matt@idevity.com) * @author Eugene Yu (eugene@idevity.com) * @author Todd E. Johnson (todd@idevity.com) * @author LaChelle Levan (lachelle@idevity.com) * * @version $Revision: 196 $ * * Changed: $LastChangedDate: 2013-07-15 11:12:55 -0400 (Mon, 15 Jul 2013) $ *****************************************************************************/ public class SettingsActivity extends PreferenceActivity { /** * Determines whether to always show the simplified settings UI, where * settings are presented in a single list. When false, settings are shown * as a master/detail two-pane view on tablets. When true, a single pane is * shown on tablets. * * private static final boolean ALWAYS_SIMPLE_PREFS = false; */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getActionBar(); getActionBar().setDisplayHomeAsUpEnabled(true); // Display the fragment as the main content. getFragmentManager().beginTransaction().replace(android.R.id.content, new SettingsFragment()).commit(); } public static class SettingsFragment extends PreferenceFragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); } } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: // This ID represents the Home or Up button. In the case of this // activity, the Up button is shown. Use NavUtils to allow users // to navigate up one level in the application structure. For // more details, see the Navigation pattern on Android Design: // // http://developer.android.com/design/patterns/navigation.html#up-vs-back NavUtils.navigateUpFromSameTask(this); return true; } return super.onOptionsItemSelected(item); } }