Last active
April 3, 2018 11:59
-
-
Save andrew-codechimp/3351362 to your computer and use it in GitHub Desktop.
[Launch Android Preference Fragment with only one header] #Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Handles the user's menu selection. | |
@Override | |
public boolean onOptionsItemSelected(MenuItem item) { | |
switch (item.getItemId()) { | |
case R.id.menu_settings: | |
@SuppressWarnings("rawtypes") | |
Class c = Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB ? PreferencesActivity.class : FragmentPreferences.class; | |
Intent i = new Intent(this, c); | |
i.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, | |
UserPreferencesFragment.class.getName()); | |
i.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true); | |
startActivityForResult(i, SHOW_PREFERENCES); | |
return true; | |
default: | |
return super.onOptionsItemSelected(item); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment