本文整理汇总了Java中android.preference.PreferenceCategory.getPreferenceCount方法的典型用法代码示例。如果您正苦于以下问题:Java PreferenceCategory.getPreferenceCount方法的具体用法?Java PreferenceCategory.getPreferenceCount怎么用?Java PreferenceCategory.getPreferenceCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.preference.PreferenceCategory
的用法示例。
在下文中一共展示了PreferenceCategory.getPreferenceCount方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initPrefSummary
import android.preference.PreferenceCategory; //导入方法依赖的package包/类
private void initPrefSummary() {
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this.getActivity());
for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); ++i) {
Preference preference = getPreferenceScreen().getPreference(i);
if (preference instanceof PreferenceCategory) {
PreferenceCategory pGrp = (PreferenceCategory) preference;
for (int j = 0; j < pGrp.getPreferenceCount(); j++) {
updatePrefSummary(pGrp.getPreference(j));
}
} else {
updatePrefSummary(preference);
}
}
}
示例2: connectDebugButtons
import android.preference.PreferenceCategory; //导入方法依赖的package包/类
/**
* Iterate through debug buttons, adding a special debug preference click
* listener to each of them.
*/
protected void connectDebugButtons() {
// Separate listener to really separate debug logic from main code paths.
final OnPreferenceClickListener listener = new DebugPreferenceClickListener();
// We don't want to use Android resource strings for debug UI, so we just
// use the keys throughout.
final PreferenceCategory debugCategory = (PreferenceCategory) ensureFindPreference("debug_category");
debugCategory.setTitle(debugCategory.getKey());
for (int i = 0; i < debugCategory.getPreferenceCount(); i++) {
final Preference button = debugCategory.getPreference(i);
button.setTitle(button.getKey()); // Not very friendly, but this is for debugging only!
button.setOnPreferenceClickListener(listener);
}
}
示例3: setSummaryPref
import android.preference.PreferenceCategory; //导入方法依赖的package包/类
public void setSummaryPref(Preference pref) {
if (pref == null)
return;
String key = pref.getKey();
if (key == null)
key = "";
if (pref instanceof KeyMapPreference) {
KeyMapPreference kbPref = (KeyMapPreference) pref;
String desc = kbPref.getDescription();
pref.setSummary(desc);
} else if (pref instanceof PreferenceCategory) {
PreferenceCategory prefCat = (PreferenceCategory) pref;
int count = prefCat.getPreferenceCount();
for (int i = 0; i < count; i++) {
setSummaryPref(prefCat.getPreference(i));
}
} else if (pref instanceof PreferenceScreen) {
setSummaryAll((PreferenceScreen) pref);
}
}
示例4: onReceive
import android.preference.PreferenceCategory; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
final String packageName = intent.getStringExtra(OpenFitIntent.EXTRA_PACKAGE_NAME);
final String appName = intent.getStringExtra(OpenFitIntent.EXTRA_APP_NAME);
Log.d(LOG_TAG, "Recieved del application: "+appName+" : "+packageName);
appManager.delNotificationApp(packageName);
oPrefs.removeSet(packageName);
oPrefs.removeString(packageName);
PreferenceCategory category = (PreferenceCategory) findPreference("preference_category_apps");
Preference app = (Preference) findPreference(packageName);
category.removePreference(app);
// If no more preference in the category, restore the placeholder
if(category.getPreferenceCount() <= 0) {
category.addPreference(preference_apps_placeholder);
}
sendNotificationApplications();
}
示例5: initSummary
import android.preference.PreferenceCategory; //导入方法依赖的package包/类
private void initSummary(Preference p) {
if (p instanceof PreferenceCategory) {
PreferenceCategory pCat = (PreferenceCategory) p;
for (int i = 0; i < pCat.getPreferenceCount(); i++) {
initSummary(pCat.getPreference(i));
}
} else {
p.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
preference.setSummary(newVal.toString());
return true;
}
});
updatePrefSummary(p);
}
}
示例6: initSummary
import android.preference.PreferenceCategory; //导入方法依赖的package包/类
private void initSummary(Preference p) {
if (p instanceof PreferenceCategory) {
PreferenceCategory pCat = (PreferenceCategory) p;
for (int i = 0; i < pCat.getPreferenceCount(); i++) {
initSummary(pCat.getPreference(i));
}
} else {
updatePrefSummary(p);
}
}
示例7: setupPeriodicControls
import android.preference.PreferenceCategory; //导入方法依赖的package包/类
private void setupPeriodicControls() {
final PreferenceCategory periodicSpeechPrefs = (PreferenceCategory) findPreference(DroidPlannerPrefs.PREF_TTS_PERIODIC);
ListPreference periodic = ((ListPreference) periodicSpeechPrefs.getPreference(0));
periodic.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, final Object newValue) {
// Broadcast the event locally on update.
// A handler is used to that the current action has the time to
// return, and store the value in the preferences.
mHandler.post(new Runnable() {
@Override
public void run() {
lbm.sendBroadcast(new Intent(ACTION_UPDATED_STATUS_PERIOD)
.putExtra(EXTRA_UPDATED_STATUS_PERIOD, (String) newValue));
setupPeriodicControls();
}
});
return true;
}
});
int val = Integer.parseInt(periodic.getValue());
final boolean isEnabled = val != 0;
if (isEnabled) {
periodic.setSummary(getString(R.string.pref_tts_status_every) + " " + val + " "
+ getString(R.string.pref_tts_seconds));
} else {
periodic.setSummary(R.string.pref_tts_periodic_status_disabled);
}
for (int i = 1; i < periodicSpeechPrefs.getPreferenceCount(); i++) {
periodicSpeechPrefs.getPreference(i).setEnabled(isEnabled);
}
}
示例8: initSummary
import android.preference.PreferenceCategory; //导入方法依赖的package包/类
private void initSummary(Preference p) {
if (p instanceof PreferenceCategory) {
PreferenceCategory cat = (PreferenceCategory) p;
for (int i = 0; i < cat.getPreferenceCount(); i++) {
initSummary(cat.getPreference(i));
}
} else {
updatePreferences(p);
}
}
示例9: setupPeriodicControls
import android.preference.PreferenceCategory; //导入方法依赖的package包/类
private void setupPeriodicControls() {
final PreferenceCategory periodicSpeechPrefs = (PreferenceCategory) findPreference(getString(R.string.pref_tts_periodic_key));
ListPreference periodic = ((ListPreference) periodicSpeechPrefs.getPreference(0));
periodic.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, final Object newValue) {
// Broadcast the event locally on update.
// A handler is used to that the current action has the time to
// return,
// and store the value in the preferences.
mHandler.post(new Runnable() {
@Override
public void run() {
LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(
new Intent(ACTION_UPDATED_STATUS_PERIOD).putExtra(
EXTRA_UPDATED_STATUS_PERIOD, (String) newValue));
setupPeriodicControls();
}
});
return true;
}
});
int val = Integer.parseInt(periodic.getValue());
final boolean isEnabled = val != 0;
if (isEnabled) {
periodic.setSummary(getString(R.string.pref_tts_status_every) + " " + val + " "
+ getString(R.string.pref_tts_seconds));
} else {
periodic.setSummary(R.string.pref_tts_periodic_status_disabled);
}
for (int i = 1; i < periodicSpeechPrefs.getPreferenceCount(); i++) {
periodicSpeechPrefs.getPreference(i).setEnabled(isEnabled);
}
}
示例10: updateSummaryForPreference
import android.preference.PreferenceCategory; //导入方法依赖的package包/类
private void updateSummaryForPreference(Preference p){
if(p instanceof ListPreference){
ListPreference lp = (ListPreference) p;
lp.setSummary(lp.getEntry());
}
if(p instanceof EditTextPreference){
EditTextPreference ep = (EditTextPreference) p;
ep.setSummary(ep.getText());
}
if(p instanceof PreferenceCategory){
PreferenceCategory pc = (PreferenceCategory) p;
for(int i=0; i < pc.getPreferenceCount(); i++)
updateSummaryForPreference(pc.getPreference(i));
}
}
示例11: initPrefsSummary
import android.preference.PreferenceCategory; //导入方法依赖的package包/类
protected void initPrefsSummary(SharedPreferences sharedPreferences,
Preference p) {
if (p instanceof PreferenceCategory) {
PreferenceCategory pCat = (PreferenceCategory) p;
for (int i = 0; i < pCat.getPreferenceCount(); i++) {
initPrefsSummary(sharedPreferences, pCat.getPreference(i));
}
} else {
updatePrefsSummary(sharedPreferences, p.getKey());
}
}
示例12: pickPreferenceObject
import android.preference.PreferenceCategory; //导入方法依赖的package包/类
private void pickPreferenceObject(Preference p) {
if (p instanceof PreferenceCategory) {
PreferenceCategory category = (PreferenceCategory) p;
for (int i = 0; i < category.getPreferenceCount(); i++) {
pickPreferenceObject(category.getPreference(i));
}
} else {
initSummary(p);
}
}
示例13: setupPeriodicControls
import android.preference.PreferenceCategory; //导入方法依赖的package包/类
private void setupPeriodicControls() {
final PreferenceCategory periodicSpeechPrefs = (PreferenceCategory) findPreference(getString(R.string.pref_tts_periodic_key));
ListPreference periodic = ((ListPreference) periodicSpeechPrefs.getPreference(0));
periodic.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, final Object newValue) {
// Broadcast the event locally on update.
// A handler is used to that the current action has the time to
// return, and store the value in the preferences.
mHandler.post(new Runnable() {
@Override
public void run() {
lbm.sendBroadcast(new Intent(ACTION_UPDATED_STATUS_PERIOD)
.putExtra(EXTRA_UPDATED_STATUS_PERIOD, (String) newValue));
setupPeriodicControls();
}
});
return true;
}
});
int val = Integer.parseInt(periodic.getValue());
final boolean isEnabled = val != 0;
if (isEnabled) {
periodic.setSummary(getString(R.string.pref_tts_status_every) + " " + val + " "
+ getString(R.string.pref_tts_seconds));
} else {
periodic.setSummary(R.string.pref_tts_periodic_status_disabled);
}
for (int i = 1; i < periodicSpeechPrefs.getPreferenceCount(); i++) {
periodicSpeechPrefs.getPreference(i).setEnabled(isEnabled);
}
}
示例14: onCreate
import android.preference.PreferenceCategory; //导入方法依赖的package包/类
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Bind the view with presenter
presenter = new Presenter(this);
presenter.getInitialize(getArguments());
PreferenceScreen preferenceScreen = getPreferenceScreen();
//START loop to set listener on Preferences
// Set "this" to listen for all preference click/change listener for all preferences
for (int i = 0, size = preferenceScreen.getPreferenceCount(); i < size; i++) {
Preference preference = preferenceScreen.getPreference(i);
preference.setOnPreferenceClickListener(this);
preference.setOnPreferenceChangeListener(this);
// If this is a preference category, make sure to go through all the subpreferences as well.
if (preference instanceof PreferenceCategory) {
Stack<PreferenceCategory> stack = new Stack<>();
stack.push((PreferenceCategory) preference);
do {
PreferenceCategory category = stack.pop();
for (int x = 0, xSize = category.getPreferenceCount(); x < xSize; x++) {
Preference subPref = category.getPreference(x);
subPref.setOnPreferenceChangeListener(this);
subPref.setOnPreferenceClickListener(this);
if (subPref instanceof PreferenceCategory) {
stack.push((PreferenceCategory) subPref);
}
}
}
while (!stack.isEmpty());
}
} //END loop to set listener on Preferences
//This will update the state of the Settings view
presenter.handlePreferences();
}