* See * Android Design: Settings for design guidelines and the Settings * API Guide for more information on developing a Settings UI. */ public class SettingsActivity extends AppCompatPreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setupActionBar(); getFragmentManager().beginTransaction().replace(android.R.id.content, new SettingsFragment()).commit(); } /** * Set up the {@link android.app.ActionBar}, if the API is available. */ private void setupActionBar() { ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { // Show the Up button in the action bar. actionBar.setDisplayHomeAsUpEnabled(true); } } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: onBackPressed(); return true; } return super.onOptionsItemSelected(item); } public static class SettingsFragment extends PreferenceFragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.pref_main); PreferenceScreen screen = getPreferenceScreen(); AppSignatureHelper signatureHelper = new AppSignatureHelper(getActivity()); ArrayList appSignatures = signatureHelper.getAppSignatures(); Preference pref = screen.findPreference("app_signature"); if (!appSignatures.isEmpty() && pref != null) { pref.setSummary(appSignatures.get(0)); } } } }