List of usage examples for android.preference PreferenceActivity onIsHidingHeaders
public boolean onIsHidingHeaders()
From source file:com.android.settings.profiles.ProfilesSettings.java
@Override public void onActivityCreated(Bundle savedInstanceState) { // We don't call super.onActivityCreated() here, since it assumes we already set up // Preference (probably in onCreate()), while ProfilesSettings exceptionally set it up in // this method. // On/off switch Activity activity = getActivity();/*from w w w.j a v a 2 s .co m*/ //Switch mActionBarSwitch = new Switch(activity); if (activity instanceof PreferenceActivity) { PreferenceActivity preferenceActivity = (PreferenceActivity) activity; if (preferenceActivity.onIsHidingHeaders() || !preferenceActivity.onIsMultiPane()) { final int padding = activity.getResources() .getDimensionPixelSize(R.dimen.action_bar_switch_padding); mActionBarSwitch.setPaddingRelative(0, 0, padding, 0); activity.getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM); activity.getActionBar().setCustomView(mActionBarSwitch, new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.END)); } } mProfileEnabler = new ProfileEnabler(activity, mActionBarSwitch); // After confirming PreferenceScreen is available, we call super. super.onActivityCreated(savedInstanceState); }