本文整理汇总了Java中android.preference.Preference.getExtras方法的典型用法代码示例。如果您正苦于以下问题:Java Preference.getExtras方法的具体用法?Java Preference.getExtras怎么用?Java Preference.getExtras使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.preference.Preference
的用法示例。
在下文中一共展示了Preference.getExtras方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resetList
import android.preference.Preference; //导入方法依赖的package包/类
private void resetList() {
getPreferenceScreen().removeAll();
addPreferencesFromResource(R.xml.usb_chooser_preferences);
if (mPermissionsByObject.isEmpty() && mSearch.isEmpty() && mEmptyView != null) {
mEmptyView.setText(R.string.website_settings_usb_no_devices);
}
for (Pair<ArrayList<UsbInfo>, ArrayList<Website>> entry : mPermissionsByObject.values()) {
Preference preference = new Preference(getActivity());
Bundle extras = preference.getExtras();
extras.putInt(UsbDevicePreferences.EXTRA_CATEGORY, mCategory.toContentSettingsType());
extras.putString(
SingleCategoryPreferences.EXTRA_TITLE, getActivity().getTitle().toString());
extras.putSerializable(UsbDevicePreferences.EXTRA_USB_INFOS, entry.first);
extras.putSerializable(UsbDevicePreferences.EXTRA_SITES, entry.second);
preference.setIcon(R.drawable.settings_usb);
preference.setTitle(entry.first.get(0).getName());
preference.setFragment(UsbDevicePreferences.class.getCanonicalName());
getPreferenceScreen().addPreference(preference);
}
}
示例2: rebuildProfileList
import android.preference.Preference; //导入方法依赖的package包/类
private void rebuildProfileList() {
// Add an edit preference for each current Chrome profile.
PreferenceGroup profileCategory = (PreferenceGroup) findPreference(PREF_AUTOFILL_PROFILES);
profileCategory.removeAll();
for (AutofillProfile profile : PersonalDataManager.getInstance().getProfilesForSettings()) {
// Add an item on the current page...
Preference pref = new Preference(getActivity());
pref.setTitle(profile.getFullName());
pref.setSummary(profile.getLabel());
if (profile.getIsLocal()) {
pref.setFragment(AutofillProfileEditor.class.getName());
} else {
pref.setWidgetLayoutResource(R.layout.autofill_server_data_label);
pref.setFragment(AutofillServerProfilePreferences.class.getName());
}
Bundle args = pref.getExtras();
args.putString(AUTOFILL_GUID, profile.getGUID());
profileCategory.addPreference(pref);
}
}
示例3: rebuildCreditCardList
import android.preference.Preference; //导入方法依赖的package包/类
private void rebuildCreditCardList() {
PreferenceGroup profileCategory =
(PreferenceGroup) findPreference(PREF_AUTOFILL_CREDIT_CARDS);
profileCategory.removeAll();
for (CreditCard card : PersonalDataManager.getInstance().getCreditCardsForSettings()) {
// Add an item on the current page...
Preference pref = new Preference(getActivity());
pref.setTitle(card.getObfuscatedNumber());
pref.setSummary(card.getFormattedExpirationDate(getActivity()));
if (card.getIsLocal()) {
pref.setFragment(AutofillLocalCardEditor.class.getName());
} else {
pref.setFragment(AutofillServerCardEditor.class.getName());
pref.setWidgetLayoutResource(R.layout.autofill_server_data_label);
}
Bundle args = pref.getExtras();
args.putString(AUTOFILL_GUID, card.getGUID());
profileCategory.addPreference(pref);
}
}
示例4: onSharedPreferenceChanged
import android.preference.Preference; //导入方法依赖的package包/类
/**
* Handles what to do when a preference is altered
*
* @param sharedPreferences to observe
* @param key of the pref that was altered
*/
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
final Preference preference = findPreference(key);
if (preference != null) {
final Bundle extras = preference.getExtras();
if (preference instanceof ListPreference) {
final String name = extras.getString("icons");
if (name != null) {
final String value = sharedPreferences.getString(key, null);
final int id = getResources()
.getIdentifier(name, "array", getActivity().getPackageName());
final TypedArray icons = getResources().obtainTypedArray(id);
final CharSequence[] entryValues
= ((ListPreference) preference).getEntryValues();
for (int x = 0; x < entryValues.length; x++) {
if (value != null && value.equals(entryValues[x])) {
setStyleIcon(preference, getResources()
.getDrawable(icons.getResourceId(x, 0)));
}
}
icons.recycle();
}
} else if (preference.getSummary() != null && preference.getSummary().equals("%s")) {
setSummary(key);
}
}
}
示例5: setSummary
import android.preference.Preference; //导入方法依赖的package包/类
/**
* Handles setting the summary after an new selection has been made
*
* @param key of the setting to update its summary for
*/
private void setSummary(String key) {
final Preference preference = findPreference(key);
if (preference != null) {
Bundle extras = preference.getExtras();
final String defaultValue = extras.getString("default");
final String value = PreferenceManager
.getDefaultSharedPreferences(mContext).getString(key, defaultValue);
preference.setSummary(value);
}
}
示例6: setPreferenceScreenType
import android.preference.Preference; //导入方法依赖的package包/类
private void setPreferenceScreenType(Class<?> classObj, String key, int type) {
Preference pf = findPreference(key);
pf.setFragment(classObj.getCanonicalName());
Bundle b = pf.getExtras();
b.putInt(PrefsLogic.EXTRA_PREFERENCE_TYPE, type);
}