本文整理匯總了Java中android.support.v7.preference.PreferenceScreen.getPreferenceCount方法的典型用法代碼示例。如果您正苦於以下問題:Java PreferenceScreen.getPreferenceCount方法的具體用法?Java PreferenceScreen.getPreferenceCount怎麽用?Java PreferenceScreen.getPreferenceCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.preference.PreferenceScreen
的用法示例。
在下文中一共展示了PreferenceScreen.getPreferenceCount方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreatePreferences
import android.support.v7.preference.PreferenceScreen; //導入方法依賴的package包/類
@Override
public void onCreatePreferences(Bundle bundle, String s) {
// Add 'general' preferences, defined in the XML file
addPreferencesFromResource(R.xml.pref_general);
SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
PreferenceScreen prefScreen = getPreferenceScreen();
int count = prefScreen.getPreferenceCount();
for (int i = 0; i < count; i++) {
Preference p = prefScreen.getPreference(i);
if (!(p instanceof CheckBoxPreference)) {
String value = sharedPreferences.getString(p.getKey(), "");
setPreferenceSummary(p, value);
}
}
}
示例2: onCreatePreferences
import android.support.v7.preference.PreferenceScreen; //導入方法依賴的package包/類
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.pref_app);
/* Get the preference screen, get the number of preferences and iterate through
all of the preferences if it is not a checkbox preference, call the setSummary method
passing in a preference and the value of the preference*/
SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
PreferenceScreen preferenceScreen = getPreferenceScreen();
int prefCount = preferenceScreen.getPreferenceCount();
for (int i = 0; i < prefCount; i++) {
Preference p = preferenceScreen.getPreference(i);
if (!(p instanceof CheckBoxPreference)) {
String value = sharedPreferences.getString(p.getKey(), "");
setPreferenceSummary(p, value);
}
}
}
示例3: onCreatePreferences
import android.support.v7.preference.PreferenceScreen; //導入方法依賴的package包/類
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.preferences);
SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
PreferenceScreen prefScreen = getPreferenceScreen();
int count = prefScreen.getPreferenceCount();
// Go through all of the preferences, and set up their preference summary.
for (int i = 0; i < count; i++) {
Preference p = prefScreen.getPreference(i);
//don't need to set up preference summaries for checkbox preferences because
// they are already set up in xml using summaryOff and summary On
if (!(p instanceof CheckBoxPreference)) {
String value = sharedPreferences.getString(p.getKey(), "");
setPreferenceSummary(p, value);
}
}
}
示例4: onCreatePreferences
import android.support.v7.preference.PreferenceScreen; //導入方法依賴的package包/類
@Override
public void onCreatePreferences(Bundle bundle, String s) {
// Add visualizer preferences, defined in the XML file in res->xml->pref_visualizer
addPreferencesFromResource(R.xml.pref_visualizer);
SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
PreferenceScreen prefScreen = getPreferenceScreen();
int count = prefScreen.getPreferenceCount();
// Go through all of the preferences, and set up their preference summary.
for (int i = 0; i < count; i++) {
Preference p = prefScreen.getPreference(i);
// You don't need to set up preference summaries for checkbox preferences because
// they are already set up in xml using summaryOff and summary On
if (!(p instanceof CheckBoxPreference)) {
String value = sharedPreferences.getString(p.getKey(), "");
setPreferenceSummary(p, value);
}
}
}
示例5: onCreatePreferences
import android.support.v7.preference.PreferenceScreen; //導入方法依賴的package包/類
@Override
public void onCreatePreferences(Bundle bundle, String s) {
// Add visualizer preferences, defined in the XML file in res->xml->pref_visualizer
addPreferencesFromResource(R.xml.pref_visualizer);
SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
PreferenceScreen prefScreen
= getPreferenceScreen();
int count = prefScreen.getPreferenceCount();
// Go through all of the preferences, and set up their preference summary.
for (int i = 0; i < count; i++) {
Preference p = prefScreen.getPreference(i);
// You don't need to set up preference summaries for checkbox preferences because
// they are already set up in xml using summaryOff and summary On
if (!(p instanceof CheckBoxPreference)) {
String value = sharedPreferences.getString(p.getKey(), "");
setPreferenceSummary(p, value);
}
}
// TODO (3) Add the OnPreferenceChangeListener specifically to the EditTextPreference
Preference preference = findPreference(getString(R.string.pref_size_key));
preference.setOnPreferenceChangeListener(this);
}
示例6: onCreatePreferences
import android.support.v7.preference.PreferenceScreen; //導入方法依賴的package包/類
@Override
public void onCreatePreferences(Bundle bundle, String s) {
// Add preferences, defined in the XML file in res->xml->preferences.xml
addPreferencesFromResource(R.xml.preferences);
//set the summaries for the different preferences for the first time
SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
PreferenceScreen prefScreen = getPreferenceScreen();
int count = prefScreen.getPreferenceCount();
for (int i = 0; i < count; i++) {
Preference p = prefScreen.getPreference(i);
// You don't need to set up preference summaries for checkbox preferences because
// they are already set up in xml using summaryOff and summary On
if (!(p instanceof CheckBoxPreference) && !(p instanceof MultiSelectListPreference)) {
String value = sharedPreferences.getString(p.getKey(), "");
setPreferenceSummary(p, value);
}
}
//attach listener to check for changes in the radius preference
//because it should only contain only doubles and the code has to enforce this
Preference preference = findPreference(getString(R.string.pref_radius_key));
preference.setOnPreferenceChangeListener(this);
}
示例7: onCreatePreferences
import android.support.v7.preference.PreferenceScreen; //導入方法依賴的package包/類
@Override
public void onCreatePreferences(Bundle bundle, String s) {
/* Add 'general' preferences, defined in the XML file */
addPreferencesFromResource(R.xml.pref_general);
// COMPLETED (9) Set the preference summary on each preference that isn't a CheckBoxPreference
SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
PreferenceScreen prefScreen = getPreferenceScreen();
int count = prefScreen.getPreferenceCount();
for (int i = 0; i < count; i++) {
Preference p = prefScreen.getPreference(i);
if (!(p instanceof CheckBoxPreference)) {
String value = sharedPreferences.getString(p.getKey(), "");
setPreferenceSummary(p, value);
}
}
}
示例8: setupLocalizedText
import android.support.v7.preference.PreferenceScreen; //導入方法依賴的package包/類
private void setupLocalizedText() {
Map<String, String> prefToTitleMap = getPrefKeyTitleMap();
if (prefToTitleMap != null) {
PreferenceScreen screen = getPreferenceScreen();
for (int i = 0; i < screen.getPreferenceCount(); i++) {
String key = screen.getPreference(i).getKey();
if (prefToTitleMap.containsKey(key)) {
try {
String localizedString = Localization.get(prefToTitleMap.get(key));
screen.getPreference(i).setTitle(localizedString);
} catch (NoLocalizedTextException nle) {
Log.w(TAG, "Unable to localize: " + prefToTitleMap.get(key));
}
}
}
}
}
示例9: getEnabledMimics
import android.support.v7.preference.PreferenceScreen; //導入方法依賴的package包/類
private ArrayList<String> getEnabledMimics() {
ArrayList<String> enabledMimics = new ArrayList<>();
PreferenceScreen preferenceScreen = getPreferenceManager().getPreferenceScreen();
for (int i = 0; i < preferenceScreen.getPreferenceCount(); i++) {
CheckBoxPreference preference = (CheckBoxPreference)preferenceScreen.getPreference(i);
if (preference.isChecked()) {
enabledMimics.add(preference.getKey());
}
}
return enabledMimics;
}
示例10: getOnScreenPrefs
import android.support.v7.preference.PreferenceScreen; //導入方法依賴的package包/類
private Preference[] getOnScreenPrefs() {
PreferenceScreen prefScreen = getPreferenceScreen();
Preference[] prefs = new Preference[prefScreen.getPreferenceCount()];
for (int i = 0; i < prefScreen.getPreferenceCount(); i++) {
prefs[i] = prefScreen.getPreference(i);
}
return prefs;
}
示例11: initSummary
import android.support.v7.preference.PreferenceScreen; //導入方法依賴的package包/類
private void initSummary(Preference pref) {
if (pref instanceof PreferenceScreen) {
final PreferenceScreen screen = (PreferenceScreen) pref;
for (int i = 0; i < screen.getPreferenceCount(); i++)
initSummary(screen.getPreference(i));
} else if (pref instanceof PreferenceCategory) {
final PreferenceCategory category = (PreferenceCategory) pref;
for (int i = 0; i < category.getPreferenceCount(); i++)
initSummary(category.getPreference(i));
} else
updatePrefSummary(pref);
}