Example usage for android.preference PreferenceScreen getPreferenceManager

List of usage examples for android.preference PreferenceScreen getPreferenceManager

Introduction

In this page you can find the example usage for android.preference PreferenceScreen getPreferenceManager.

Prototype

public PreferenceManager getPreferenceManager() 

Source Link

Document

Gets the PreferenceManager that manages this Preference object's tree.

Usage

From source file:net.basilwang.StaticAttachmentActivity.java

 @Override
public void onPreferenceAttached(PreferenceScreen root, int xmlId) {
   if (root == null)
      return; // for whatever reason in very rare cases this is null
   if (xmlId == R.xml.preferencesfragment) {
      PreferenceCategory logonPreference;
      PreferenceScreen logonAddPreference;
      PreferenceScreen aboutusPreference;
      PreferenceScreen shareonweiboPreference;
      // PreferenceScreen ruguozhaiPreference;
      // The filelds we have deleted
      // CheckBoxPreference weekViewCheckboxPreference;
      // CheckBoxPreference scoreCheckboxPreference;
      CheckBoxPreference adCheckboxPreference;
      logonAddPreference = (PreferenceScreen) root
            .findPreference(LOGON_ADD_PREFERENCES);
      if (logonAddPreference != null) {
         logonAddPreference.setOnPreferenceClickListener(this);
      }//from   w ww .jav a  2  s . com
      logonPreference = (PreferenceCategory) root
            .findPreference(LOGON_PREFERENCES);

      aboutusPreference = (PreferenceScreen) root
            .findPreference(ABOUT_US);
      shareonweiboPreference = (PreferenceScreen) root
            .findPreference(SHAREONWEIBO);

      // ruguozhaiPreference = (PreferenceScreen) root
      // .findPreference(RU_GUO_ZHAI);

      adCheckboxPreference = (CheckBoxPreference) root
            .findPreference(CLOSE_AD);
      // weekViewCheckboxPreference = (CheckBoxPreference) root
      // .findPreference(WEEKVIEW_ENABLED);
      // 2012-09-26 basilwang if weekview already enabled, we set
      // WeekViewCheckboxPreference enable status is false
      // if (Preferences.isWeekViewUnlocked(this)) {
      // weekViewCheckboxPreference.setChecked(true);
      // weekViewCheckboxPreference.setEnabled(false);
      // } else {
      // weekViewCheckboxPreference.setChecked(false);
      // weekViewCheckboxPreference.setEnabled(true);
      // }
      if (Preferences.isAdClosed(this)) {
         adCheckboxPreference.setChecked(true);
         adCheckboxPreference.setEnabled(false);
      } else {
         adCheckboxPreference.setChecked(false);
         adCheckboxPreference.setEnabled(true);
      }
      aboutusPreference.setOnPreferenceClickListener(this);
      shareonweiboPreference.setOnPreferenceClickListener(this);
      // ruguozhaiPreference.setOnPreferenceClickListener(this);
      // weekViewCheckboxPreference.setOnPreferenceClickListener(this);
      adCheckboxPreference.setOnPreferenceClickListener(this);
      YoumiOffersManager.init(this, "2fc95b356bb979ae",
            "8b94f727980f7158");
      YoumiOffersManager.checkStatus(StaticAttachmentActivity.this,
            StaticAttachmentActivity.this);
      reloadData(logonPreference, logonAddPreference,
            root.getPreferenceManager());
   }
}