本文整理匯總了Java中android.preference.PreferenceScreen.findPreference方法的典型用法代碼示例。如果您正苦於以下問題:Java PreferenceScreen.findPreference方法的具體用法?Java PreferenceScreen.findPreference怎麽用?Java PreferenceScreen.findPreference使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.preference.PreferenceScreen
的用法示例。
在下文中一共展示了PreferenceScreen.findPreference方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: resetList
import android.preference.PreferenceScreen; //導入方法依賴的package包/類
private void resetList() {
getPreferenceScreen().removeAll();
addPreferencesFromResource(R.xml.usb_device_preferences);
PreferenceScreen preferenceScreen = getPreferenceScreen();
Preference header = preferenceScreen.findPreference(PREF_OBJECT_NAME);
header.setTitle(mUsbInfo.getName());
header.setOnPreferenceClickListener(this);
for (int i = 0; i < mSites.size(); ++i) {
Website site = mSites.get(i);
Preference preference = new WebsitePreference(getActivity(), site, mCategory);
preference.getExtras().putSerializable(SingleWebsitePreferences.EXTRA_SITE, site);
preference.setFragment(SingleWebsitePreferences.class.getCanonicalName());
preferenceScreen.addPreference(preference);
}
// Force this list to be reloaded if the activity is resumed.
mSites = null;
}
示例2: onCreate
import android.preference.PreferenceScreen; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.battery_light_settings);
PreferenceScreen prefSet = getPreferenceScreen();
PreferenceGroup mGeneralPrefs = (PreferenceGroup) prefSet.findPreference("general_section");
mLightEnabledPref = (CMSystemSettingSwitchPreference) prefSet.findPreference(LIGHT_ENABLED_PREF);
mPulseEnabledPref = (CMSystemSettingSwitchPreference) prefSet.findPreference(PULSE_ENABLED_PREF);
if (!getResources().getBoolean(com.android.internal.R.bool.config_ledCanPulse) ||
getResources().getBoolean(org.cyanogenmod.platform.internal.R.bool.config_useSegmentedBatteryLed)) {
mGeneralPrefs.removePreference(mPulseEnabledPref);
}
// Does the Device support changing battery LED colors?
if (getResources().getBoolean(com.android.internal.R.bool.config_multiColorBatteryLed)) {
setHasOptionsMenu(true);
// Low, Medium and full color preferences
mLowColorPref = (ApplicationLightPreference) prefSet.findPreference(LOW_COLOR_PREF);
mLowColorPref.setOnPreferenceChangeListener(this);
mMediumColorPref = (ApplicationLightPreference) prefSet.findPreference(MEDIUM_COLOR_PREF);
mMediumColorPref.setOnPreferenceChangeListener(this);
mFullColorPref = (ApplicationLightPreference) prefSet.findPreference(FULL_COLOR_PREF);
mFullColorPref.setOnPreferenceChangeListener(this);
} else {
prefSet.removePreference(prefSet.findPreference("colors_list"));
resetColors();
}
}
示例3: onCreateInternal
import android.preference.PreferenceScreen; //導入方法依賴的package包/類
@Override
protected void onCreateInternal() {
addPreferencesFromResource(R.xml.zen_mode_external_rule_settings);
final PreferenceScreen root = getPreferenceScreen();
final ServiceInfo si = ServiceListing.findService(mContext,
ZenModeAutomationSettings.CONFIG, mRule.component);
if (DEBUG) Log.d(TAG, "ServiceInfo: " + si);
final RuleInfo ri = getRuleInfo(si);
if (DEBUG) Log.d(TAG, "RuleInfo: " + ri);
mType = root.findPreference(KEY_TYPE);
if (ri == null) {
mType.setSummary(R.string.zen_mode_rule_type_unknown);
} else {
mType.setSummary(ri.caption);
}
mConfigure = root.findPreference(KEY_CONFIGURE);
if (ri == null || ri.configurationActivity == null) {
mConfigure.setEnabled(false);
} else {
mConfigure.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
startActivityForResult(new Intent().setComponent(ri.configurationActivity),
REQUEST_CODE_CONFIGURE);
return true;
}
});
}
}
示例4: onCreate
import android.preference.PreferenceScreen; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
mContext = getActivity();
final Intent intent = getActivity().getIntent();
if (DEBUG) Log.d(TAG, "onCreate getIntent()=" + intent);
if (intent == null) {
Log.w(TAG, "No intent");
toastAndFinish();
return;
}
mRuleId = intent.getStringExtra(EXTRA_RULE_ID);
if (DEBUG) Log.d(TAG, "mRuleId=" + mRuleId);
if (refreshRuleOrFinish()) {
return;
}
setHasOptionsMenu(true);
onCreateInternal();
final PreferenceScreen root = getPreferenceScreen();
mRuleName = root.findPreference(KEY_RULE_NAME);
mRuleName.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
showRuleNameDialog();
return true;
}
});
mZenMode = (DropDownPreference) root.findPreference(KEY_ZEN_MODE);
mZenMode.addItem(R.string.zen_mode_option_important_interruptions,
Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
mZenMode.addItem(R.string.zen_mode_option_alarms, Global.ZEN_MODE_ALARMS);
mZenMode.addItem(R.string.zen_mode_option_no_interruptions,
Global.ZEN_MODE_NO_INTERRUPTIONS);
mZenMode.setCallback(new DropDownPreference.Callback() {
@Override
public boolean onItemSelected(int pos, Object value) {
if (mDisableListeners) return true;
final int zenMode = (Integer) value;
if (zenMode == mRule.zenMode) return true;
if (DEBUG) Log.d(TAG, "onPrefChange zenMode=" + zenMode);
mRule.zenMode = zenMode;
setZenModeConfig(mConfig);
return true;
}
});
mZenMode.setOrder(10); // sort at the bottom of the category
mZenMode.setDependency(getZenModeDependency());
}
示例5: onCreate
import android.preference.PreferenceScreen; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.zen_mode_settings);
final PreferenceScreen root = getPreferenceScreen();
mPrioritySettings = root.findPreference(KEY_PRIORITY_SETTINGS);
if (!isScheduleSupported(mContext)) {
removePreference(KEY_AUTOMATION_SETTINGS);
}
mZenAccess = findPreference(KEY_ZEN_ACCESS);
refreshZenAccess();
}
示例6: setPreferenceEnabled
import android.preference.PreferenceScreen; //導入方法依賴的package包/類
static void setPreferenceEnabled(final String prefKey, final boolean enabled,
final PreferenceScreen screen) {
final Preference preference = screen.findPreference(prefKey);
if (preference != null) {
preference.setEnabled(enabled);
}
}
示例7: updateListPreferenceSummaryToCurrentValue
import android.preference.PreferenceScreen; //導入方法依賴的package包/類
static void updateListPreferenceSummaryToCurrentValue(final String prefKey,
final PreferenceScreen screen) {
// Because the "%s" summary trick of {@link ListPreference} doesn't work properly before
// KitKat, we need to update the summary programmatically.
final ListPreference listPreference = (ListPreference)screen.findPreference(prefKey);
if (listPreference == null) {
return;
}
final CharSequence entries[] = listPreference.getEntries();
final int entryIndex = listPreference.findIndexOfValue(listPreference.getValue());
listPreference.setSummary(entryIndex < 0 ? null : entries[entryIndex]);
}
示例8: setPasswordFieldSummary
import android.preference.PreferenceScreen; //導入方法依賴的package包/類
/**
* Set summary of a password field If empty will display default summary If
* password will display a * char for each letter of password
*
* @param fieldName the preference key name
*/
public void setPasswordFieldSummary(String fieldName) {
PreferenceScreen pfs = getPreferenceScreen();
SharedPreferences sp = pfs.getSharedPreferences();
Preference pref = pfs.findPreference(fieldName);
String val = sp.getString(fieldName, null);
if (TextUtils.isEmpty(val)) {
val = getDefaultFieldSummary(fieldName);
} else {
val = val.replaceAll(".", "*");
}
setPreferenceSummary(pref, val);
}
示例9: setListFieldSummary
import android.preference.PreferenceScreen; //導入方法依賴的package包/類
/**
* Set summary of a list field If empty will display default summary If one
* item selected will display item name
*
* @param fieldName the preference key name
*/
public void setListFieldSummary(String fieldName) {
PreferenceScreen pfs = getPreferenceScreen();
ListPreference pref = (ListPreference) pfs.findPreference(fieldName);
if (pref == null) {
Log.w(THIS_FILE, "Unable to find preference " + fieldName);
return;
}
CharSequence val = pref.getEntry();
if (TextUtils.isEmpty(val)) {
val = getDefaultFieldSummary(fieldName);
}
setPreferenceSummary(pref, val);
}
示例10: updateTechnicalInfo
import android.preference.PreferenceScreen; //導入方法依賴的package包/類
private void updateTechnicalInfo() {
PreferenceScreen screen = getPreferenceScreen();
Preference pref_technical_info = screen.findPreference("technical_info");
Preference pref_technical_network = screen.findPreference("technical_network");
Preference pref_technical_subscription = screen.findPreference("technical_subscription");
pref_technical_info.setSummary(Util.getGeneralInfo(this));
pref_technical_network.setSummary(Util.getNetworkInfo(this));
pref_technical_subscription.setSummary(Util.getSubscriptionInfo(this));
}
示例11: hasPermissionsPreferences
import android.preference.PreferenceScreen; //導入方法依賴的package包/類
private boolean hasPermissionsPreferences() {
if (mUsbPermissionCount > 0) return true;
PreferenceScreen screen = getPreferenceScreen();
for (String key : PERMISSION_PREFERENCE_KEYS) {
if (screen.findPreference(key) != null) return true;
}
return false;
}
示例12: onPreferenceClick
import android.preference.PreferenceScreen; //導入方法依賴的package包/類
@Override
public boolean onPreferenceClick(Preference preference) {
Bundle extras = preference.peekExtras();
if (extras != null) {
UsbInfo usbInfo = (UsbInfo) extras.getSerializable(EXTRA_USB_INFO);
if (usbInfo != null) {
usbInfo.revoke();
PreferenceScreen preferenceScreen = getPreferenceScreen();
preferenceScreen.removePreference(preference);
mUsbPermissionCount--;
if (!hasPermissionsPreferences()) {
Preference heading = preferenceScreen.findPreference(PREF_PERMISSIONS);
preferenceScreen.removePreference(heading);
}
return true;
}
}
// Handle the Clear & Reset preference click by showing a confirmation.
new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
.setTitle(R.string.website_reset)
.setMessage(R.string.website_reset_confirmation)
.setPositiveButton(R.string.website_reset, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
resetSite();
}
})
.setNegativeButton(R.string.cancel, null)
.show();
return true;
}
示例13: loadPreferences
import android.preference.PreferenceScreen; //導入方法依賴的package包/類
private void loadPreferences() {
addPreferencesFromResource(R.xml.preferences);
final PreferenceScreen screen = getPreferenceScreen();
mCheckBoxEnabled = (CheckBoxPreference)screen.findPreference(getString(R.string.preference_enabled));
mVibratePart = (ListPreference)screen.findPreference(getString(R.string.preference_vibrate_parts));
mTestText = (EditTextPreference)screen.findPreference(getString(R.string.preference_test));
mVibrateCounts = (CheckBoxPreference)screen.findPreference(getString(R.string.preference_vibrate_counts));
mDotLength = (BetterSeekBarPreference)screen.findPreference(getString(R.string.preference_dot_length));
mCheckBoxEnabled.setOnPreferenceChangeListener(mEnabledListener);
mVibratePart.setOnPreferenceChangeListener(mVibratePartListener);
//Trigger summary update
mVibratePartListener.onPreferenceChange(mVibratePart, mVibratePart.getValue());
mTestText.setOnPreferenceChangeListener(mTestTextListener);
mScreenOffOnly = (CheckBoxPreference)screen.findPreference(getString(R.string.preference_screen_off_only));
mActiveNormal = (CheckBoxPreference)screen.findPreference(getString(R.string.preference_vibrate_normal));
mActiveVibrate = (CheckBoxPreference)screen.findPreference(getString(R.string.preference_vibrate_vibrate));
mActiveSilent = (CheckBoxPreference)screen.findPreference(getString(R.string.preference_vibrate_silent));
//mCheckBoxInputEnabled = (CheckBoxPreference)screen.findPreference(getString(R.string.preference_input_enabled));
//mCheckBoxInputEnabled.setOnPreferenceChangeListener(mInputEnabledListener);
final DialogPreference about = (DialogPreference)screen.findPreference(getString(R.string.preference_about));
about.setDialogLayoutResource(R.layout.about);
try {
final String version = getPackageManager().getPackageInfo("com.jakewharton.smsmorse", PackageManager.GET_META_DATA).versionName;
about.setDialogTitle(getString(R.string.app_name) + " v" + version);
} catch (Exception e) {}
}
示例14: findDecodePrefs
import android.preference.PreferenceScreen; //導入方法依賴的package包/類
private static CheckBoxPreference[] findDecodePrefs(PreferenceScreen preferences, String... keys) {
CheckBoxPreference[] prefs = new CheckBoxPreference[keys.length];
for (int i = 0; i < keys.length; i++) {
prefs[i] = (CheckBoxPreference) preferences.findPreference(keys[i]);
}
return prefs;
}
示例15: removePreference
import android.preference.PreferenceScreen; //導入方法依賴的package包/類
static void removePreference(final String prefKey, final PreferenceScreen screen) {
final Preference preference = screen.findPreference(prefKey);
if (preference != null) {
screen.removePreference(preference);
}
}