List of usage examples for android.preference PreferenceScreen setEnabled
public void setEnabled(boolean enabled)
From source file:net.basilwang.StaticAttachmentActivity.java
private void reloadData(PreferenceCategory logonPreference, PreferenceScreen logonAddPreference, PreferenceManager preferenceManager) { // 2012-11-23 basilwang refresh tabbar title refreshActionBarTitle();//from w w w . j a v a2s. c o m 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); } } }