Example usage for android.preference PreferenceActivity onIsHidingHeaders

List of usage examples for android.preference PreferenceActivity onIsHidingHeaders

Introduction

In this page you can find the example usage for android.preference PreferenceActivity onIsHidingHeaders.

Prototype

public boolean onIsHidingHeaders() 

Source Link

Document

Called to determine whether the header list should be hidden.

Usage

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);
}