本文整理汇总了Java中android.preference.PreferenceCategory.getPreference方法的典型用法代码示例。如果您正苦于以下问题:Java PreferenceCategory.getPreference方法的具体用法?Java PreferenceCategory.getPreference怎么用?Java PreferenceCategory.getPreference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.preference.PreferenceCategory
的用法示例。
在下文中一共展示了PreferenceCategory.getPreference方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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);
}
}
示例3: 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);
}
}
示例4: 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);
}
}
示例5: 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();
}
示例6: updateInfoPref
import android.preference.PreferenceCategory; //导入方法依赖的package包/类
private void updateInfoPref(PreferenceCategory category, int index, int helpId, boolean isOn) {
TwoStatePreference pref = (TwoStatePreference) category.getPreference(index);
pref.setChecked(isOn);
pref.setOnPreferenceChangeListener(this);
pref.setIntent(getHelpIntent(helpId));
}