本文整理汇总了Java中android.preference.PreferenceGroup.getPreferenceCount方法的典型用法代码示例。如果您正苦于以下问题:Java PreferenceGroup.getPreferenceCount方法的具体用法?Java PreferenceGroup.getPreferenceCount怎么用?Java PreferenceGroup.getPreferenceCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.preference.PreferenceGroup
的用法示例。
在下文中一共展示了PreferenceGroup.getPreferenceCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setChildrenStarted
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
private void setChildrenStarted(PreferenceGroup group, boolean started) {
final int count = group.getPreferenceCount();
for (int i = 0; i < count; i++) {
Preference pref = group.getPreference(i);
if (pref instanceof ApplicationLightPreference) {
ApplicationLightPreference ap = (ApplicationLightPreference) pref;
if (started) {
ap.onStart();
} else {
ap.onStop();
}
} else if (pref instanceof PreferenceGroup) {
setChildrenStarted((PreferenceGroup) pref, started);
}
}
}
示例2: onPause
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
@Override
protected void onPause() {
super.onPause();
// Save the selected languages
String checkedLanguages = "";
PreferenceGroup parent = getPreferenceScreen();
int count = parent.getPreferenceCount();
for (int i = 0; i < count; i++) {
CheckBoxPreference pref = (CheckBoxPreference) parent.getPreference(i);
if (pref.isChecked()) {
Locale locale = mAvailableLanguages.get(i).locale;
checkedLanguages += get5Code(locale) + ",";
}
}
if (checkedLanguages.length() < 1) checkedLanguages = null; // Save null
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
Editor editor = sp.edit();
editor.putString(KP2AKeyboard.PREF_SELECTED_LANGUAGES, checkedLanguages);
SharedPreferencesCompat.apply(editor);
}
示例3: onResume
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
@Override
public void onResume() {
super.onResume();
//Atribui os valores selecionados
for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); ++i) {
Preference preference = getPreferenceScreen().getPreference(i);
if (preference instanceof PreferenceGroup) {
PreferenceGroup preferenceGroup = (PreferenceGroup) preference;
for (int j = 0; j < preferenceGroup.getPreferenceCount(); ++j) {
updatePreference(preferenceGroup.getPreference(j));
}
} else {
updatePreference(preference);
}
}
}
示例4: getPreferenceList
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
/**
* Gets the list of preferences in a PreferenceScreen
*
* @param p preference to add to the list
* @param list of preferences in the PreferenceScreen
* @return a list of all the preferences
*/
private ArrayList<Preference> getPreferenceList(Preference p, ArrayList<Preference> list) {
if (p instanceof PreferenceCategory || p instanceof PreferenceScreen) {
PreferenceGroup prefGroup = (PreferenceGroup) p;
final int prefCount = prefGroup.getPreferenceCount();
for (int i = 0; i < prefCount; i++) {
getPreferenceList(prefGroup.getPreference(i), list);
}
}
if (!(p instanceof PreferenceCategory)) {
list.add(p);
}
return list;
}
示例5: replaceAllCheckBoxPreferencesBySwitchPreferences
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
private static void replaceAllCheckBoxPreferencesBySwitchPreferences(
final PreferenceGroup group) {
final ArrayList<Preference> preferences = new ArrayList<>();
final int count = group.getPreferenceCount();
for (int index = 0; index < count; index++) {
preferences.add(group.getPreference(index));
}
group.removeAll();
for (int index = 0; index < count; index++) {
final Preference preference = preferences.get(index);
if (preference instanceof CheckBoxPreference) {
addSwitchPreferenceBasedOnCheckBoxPreference((CheckBoxPreference)preference, group);
} else {
group.addPreference(preference);
if (preference instanceof PreferenceGroup) {
replaceAllCheckBoxPreferencesBySwitchPreferences((PreferenceGroup)preference);
}
}
}
}
示例6: findWordListPreference
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
private WordListPreference findWordListPreference(final String id) {
final PreferenceGroup prefScreen = getPreferenceScreen();
if (null == prefScreen) {
Log.e(TAG, "Could not find the preference group");
return null;
}
for (int i = prefScreen.getPreferenceCount() - 1; i >= 0; --i) {
final Preference pref = prefScreen.getPreference(i);
if (pref instanceof WordListPreference) {
final WordListPreference wlPref = (WordListPreference)pref;
if (id.equals(wlPref.mWordlistId)) {
return wlPref;
}
}
}
Log.e(TAG, "Could not find the preference for a word list id " + id);
return null;
}
示例7: bind
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
private void bind(PreferenceGroup group) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
for (int i = 0; i < group.getPreferenceCount(); i++) {
Preference p = group.getPreference(i);
if (p instanceof PreferenceGroup) {
bind((PreferenceGroup) p);
} else {
if (p instanceof CheckBoxPreference) {
;
} else {
Object val = sp.getAll().get(p.getKey());
p.setSummary(val == null ? "" : ("" + val));
p.setOnPreferenceChangeListener(this);
}
}
}
}
示例8: getPreferenceList
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
private List<Preference> getPreferenceList(Preference p, List<Preference> list)
{
if (p instanceof PreferenceCategory || p instanceof PreferenceScreen)
{
PreferenceGroup g = (PreferenceGroup) p;
int pCount = g.getPreferenceCount();
for (int i = 0; i < pCount; i++)
{
getPreferenceList(g.getPreference(i), list);
}
}
else
{
list.add(p);
}
return list;
}
示例9: onPause
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
@Override
protected void onPause() {
super.onPause();
// Save the selected languages
String checkedLanguages = "";
PreferenceGroup parent = getPreferenceScreen();
int count = parent.getPreferenceCount();
for (int i = 0; i < count; i++) {
CheckBoxPreference pref = (CheckBoxPreference) parent.getPreference(i);
if (pref.isChecked()) {
Locale locale = mAvailableLanguages.get(i).locale;
checkedLanguages += get5Code(locale) + ",";
}
}
if (checkedLanguages.length() < 1) checkedLanguages = null; // Save null
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
Editor editor = sp.edit();
editor.putString(LatinIME.PREF_SELECTED_LANGUAGES, checkedLanguages);
SharedPreferencesCompat.apply(editor);
}
示例10: onActivityCreated
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
PreferenceScreen preferenceScreen = getPreferenceScreen();
SharedPreferenceListener sharedPreferenceListener = new SharedPreferenceListener();
for(int idPreference = 0; idPreference < preferenceScreen.getPreferenceCount(); idPreference++) {
Preference preference = preferenceScreen.getPreference(idPreference);
if(preference instanceof PreferenceGroup) {
PreferenceGroup preferenceGroup = (PreferenceGroup)preference;
for(int IdGroupReference = 0; IdGroupReference < preferenceGroup.getPreferenceCount(); IdGroupReference++) {
preference = preferenceGroup.getPreference(IdGroupReference);
preference.setOnPreferenceChangeListener(sharedPreferenceListener);
}
} else {
preference.setOnPreferenceChangeListener(sharedPreferenceListener);
}
}
}
示例11: onResume
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
/**
* On resume it update every settings.
*/
@Override
public void onResume() {
super.onResume();
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); i++) {
Preference preference = getPreferenceScreen().getPreference(i);
if (preference instanceof PreferenceGroup) {
PreferenceGroup preferenceGroup = (PreferenceGroup) preference;
for (int j = 0; j < preferenceGroup.getPreferenceCount(); ++j) {
updatePreference(preferenceGroup.getPreference(j));
}
} else {
updatePreference(preference);
}
}
}
示例12: onResume
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
@Override
public void onResume() {
super.onResume();
PreferenceScreen preferenceScreen = getPreferenceScreen();
for (int i = 0; i < preferenceScreen.getPreferenceCount(); i++) {
Preference preference = preferenceScreen.getPreference(i);
if (preference instanceof PreferenceGroup) {
PreferenceGroup preferenceGroup = (PreferenceGroup) preference;
for (int j = 0; j < preferenceGroup.getPreferenceCount(); j++) {
Preference subPref = preferenceGroup.getPreference(j);
updatePreference(subPref, subPref.getKey());
}
} else {
updatePreference(preference, preference.getKey());
}
}
}
示例13: putAllPreferences
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
private void putAllPreferences(PreferenceGroup group) {
int c = 0;
String advancedPrefix = mActivity.getString(string.pref_advanced_prefix);
while(c < group.getPreferenceCount()) {
String key;
Preference preference = group.getPreference(c);
if(preference instanceof PreferenceGroup) {
putAllPreferences((PreferenceGroup)preference);
key = preference.getKey();
} else {
key = String.format("%s.%s", group.getKey(), preference.getKey());
}
setProperty(key, String.valueOf(!preference.getKey().startsWith(advancedPrefix)));
c++;
}
}
示例14: hideAdvancedPreferences
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
private void hideAdvancedPreferences(PreferenceGroup group) {
if(mAdvancedSettings.showAll()) {
return;
}
int c = 0;
while(c < group.getPreferenceCount()) {
Preference pref = group.getPreference(c);
if(!mAdvancedSettings.isVisible(group, pref)) {
group.removePreference(pref);
} else {
if(pref instanceof PreferenceGroup) {
hideAdvancedPreferences((PreferenceGroup)pref);
}
c++;
}
}
}
示例15: onResume
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
@Override
public void onResume() {
super.onResume();
SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
// Register self als listener for changes
sharedPreferences.registerOnSharedPreferenceChangeListener(this);
// Set initial summary state
for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); i++) {
Preference preference = getPreferenceScreen().getPreference(i);
if (preference instanceof PreferenceGroup) {
PreferenceGroup preferenceGroup = (PreferenceGroup) preference;
for (int j = 0; j < preferenceGroup.getPreferenceCount(); j++) {
updatePreferenceSummary(sharedPreferences, preferenceGroup.getPreference(j));
}
} else {
updatePreferenceSummary(sharedPreferences, preference);
}
}
}