List of usage examples for android.preference PreferenceScreen setOnPreferenceClickListener
public void setOnPreferenceClickListener(OnPreferenceClickListener onPreferenceClickListener)
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); }/* w ww . j av a 2s. c o m*/ 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()); } }
From source file:net.basilwang.StaticAttachmentActivity.java
private void reloadData(PreferenceCategory logonPreference, PreferenceScreen logonAddPreference, PreferenceManager preferenceManager) { // 2012-11-23 basilwang refresh tabbar title refreshActionBarTitle();/*w ww .j av a 2s . c om*/ logonPreference.removeAll(); logonPreference.addPreference(logonAddPreference); int accountId = PreferenceManager.getDefaultSharedPreferences(this) .getInt(LOGON_ACCOUNT_ID, 0); AccountService service = new AccountService(this); List<Account> list = service.getAccounts(); if (list.size() == 0) { logonAddPreference.setEnabled(true); } else { logonAddPreference.setEnabled(false); for (Account account : list) { PreferenceScreen preferenceItem = preferenceManager .createPreferenceScreen(this); // CheckBoxPreference checkBoxPreference = new // CheckBoxPreference(this); // make sure each key is unique preferenceItem.setKey(LOGON_ACCOUNT_PREFERENCES); preferenceItem.setTitle(PreferenceUtils.getPreferUserName(this)); if (accountId == account.getId()) preferenceItem.setSummary(R.string.already_checked); // preferenceItem.setChecked(false); // checkBoxPreference.setDisableDependentsState(disableDependentsState) // checkBoxPreference.setSelectable(false); preferenceItem.setOrder(0); preferenceItem.setOnPreferenceClickListener(this); logonPreference.addPreference(preferenceItem); } } }