本文整理汇总了Java中android.preference.Preference.setTitle方法的典型用法代码示例。如果您正苦于以下问题:Java Preference.setTitle方法的具体用法?Java Preference.setTitle怎么用?Java Preference.setTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.preference.Preference
的用法示例。
在下文中一共展示了Preference.setTitle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: disableOnlyFullAppPrefs
import android.preference.Preference; //导入方法依赖的package包/类
private void disableOnlyFullAppPrefs() {
String fullOnly = " FULL ONLY ";
int color = Utils.adjustAlpha(CurrentTheme.getColorAccent(getActivity()), 100);
for (String name : AppPrefs.ONLY_FULL_APP_PREFS) {
Preference preference = findPreference(name);
if (preference != null) {
preference.setEnabled(false);
CharSequence summary = TextUtils.isEmpty(preference.getTitle()) ? "" : preference.getTitle();
summary = fullOnly + " " + summary;
Spannable spannable = SpannableStringBuilder.valueOf(summary);
BackgroundColorSpan span = new BackgroundColorSpan(color);
ForegroundColorSpan span1 = new ForegroundColorSpan(Color.WHITE);
spannable.setSpan(span, 0, fullOnly.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
spannable.setSpan(span1, 0, fullOnly.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
preference.setTitle(spannable);
}
}
}
示例2: refreshPreferences
import android.preference.Preference; //导入方法依赖的package包/类
private void refreshPreferences() {
mProfiles.removeAll();
mSingleSettings = SambaConfiguration.getSingleSettingList();
int length = mSingleSettings.size();
Activity activity = getActivity();
for (int index = 0; index < length; index++) {
String section = mSingleSettings.get(index);
SambaSingleSetting sss = SambaConfiguration.getSingleSetting(section);
Preference pref = new Preference(activity);
pref.setTitle(section);
pref.setSummary(sss.getUsername());
pref.setOrder(index);
mProfiles.addPreference(pref);
}
}
示例3: 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);
}
}
示例4: resetList
import android.preference.Preference; //导入方法依赖的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;
}
示例5: 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);
}
}
示例6: 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);
}
}
示例7: onCreate
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.layout.preferences);
Preference about = findPreference("ABOUT");
if(about != null) {
String versionName = "";
try {
versionName = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName;
}
catch(NameNotFoundException e) {
e.printStackTrace();
}
about.setTitle(about.getTitle() + " " + versionName);
}
}
示例8: onCreate
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.layout.help);
Preference about = findPreference("ABOUT");
if(about != null) {
String versionName = "";
try {
versionName = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName;
}
catch(NameNotFoundException e) {
e.printStackTrace();
}
about.setTitle(about.getTitle() + " " + versionName);
}
}
示例9: UpgradePro
import android.preference.Preference; //导入方法依赖的package包/类
private void UpgradePro() {
Preference darkKey = findPreference("DARK_THEME_KEY");
darkKey.setEnabled(true);
darkKey.setTitle(R.string.DarkThemePro);
Preference SmallFonts = findPreference("EXTRA_SMALL_FONT");
SmallFonts.setEnabled(true);
SmallFonts.setTitle(R.string.ExtraSmallFontTPro);
Preference Rounding = findPreference("ROUNDIND_INFO");
Rounding.setTitle(R.string.EnableRoundingPro);
Rounding.setEnabled(true);
Preference Max = findPreference("MAX_INT");
Max.setEnabled(true);
Max.setTitle(R.string.MaximumTPro);
Preference Min = findPreference("MIN_INT_KEY");
Min.setTitle(R.string.MinimumTPro);
Min.setEnabled(true);
}
示例10: initializeDefaultPreference
import android.preference.Preference; //导入方法依赖的package包/类
private void initializeDefaultPreference() {
if (VERSION.SDK_INT < VERSION_CODES.KITKAT) return;
Preference defaultPreference = findPreference(KITKAT_DEFAULT_PREF);
if (Util.isDefaultSmsProvider(getActivity())) {
defaultPreference.setIntent(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
defaultPreference.setTitle(getString(R.string.ApplicationPreferencesActivity_sms_enabled));
defaultPreference.setSummary(getString(R.string.ApplicationPreferencesActivity_touch_to_change_your_default_sms_app));
} else {
Intent intent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, getActivity().getPackageName());
defaultPreference.setIntent(intent);
defaultPreference.setTitle(getString(R.string.ApplicationPreferencesActivity_sms_disabled));
defaultPreference.setSummary(getString(R.string.ApplicationPreferencesActivity_touch_to_make_signal_your_default_sms_app));
}
}
示例11: createUserDictionaryPreference
import android.preference.Preference; //导入方法依赖的package包/类
/**
* Create a single User Dictionary Preference object, with its parameters set.
* @param localeString The locale for which this user dictionary is for.
* @return The corresponding preference.
*/
protected Preference createUserDictionaryPreference(@Nullable final String localeString) {
final Preference newPref = new Preference(getActivity());
final Intent intent = new Intent(USER_DICTIONARY_SETTINGS_INTENT_ACTION);
if (null == localeString) {
newPref.setTitle(Locale.getDefault().getDisplayName());
} else {
if (localeString.isEmpty()) {
newPref.setTitle(getString(R.string.user_dict_settings_all_languages));
} else {
newPref.setTitle(
LocaleUtils.constructLocaleFromString(localeString).getDisplayName());
}
intent.putExtra("locale", localeString);
newPref.getExtras().putString("locale", localeString);
}
newPref.setIntent(intent);
newPref.setFragment(UserDictionarySettings.class.getName());
return newPref;
}
示例12: updateSubtypeEnabler
import android.preference.Preference; //导入方法依赖的package包/类
public void updateSubtypeEnabler() {
final Preference pref = mSubtypeEnablerPreference;
if (pref == null) {
return;
}
final Context context = pref.getContext();
final CharSequence title;
if (mSubtypeEnablerTitleRes != 0) {
title = context.getString(mSubtypeEnablerTitleRes);
} else {
title = mSubtypeEnablerTitle;
}
pref.setTitle(title);
final Intent intent = pref.getIntent();
if (intent != null) {
intent.putExtra(Intent.EXTRA_TITLE, title);
}
final String summary = getEnabledSubtypesLabel(context, mImm, mImi);
if (!TextUtils.isEmpty(summary)) {
pref.setSummary(summary);
}
if (mSubtypeEnablerIconRes != 0) {
pref.setIcon(mSubtypeEnablerIconRes);
} else {
pref.setIcon(mSubtypeEnablerIcon);
}
}
示例13: onStart
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public void onStart() {
super.onStart();
getPreferenceScreen().removeAll();
String[] colorNames = getResources().getStringArray(colorNamesId);
TypedArray colorValues = getResources().obtainTypedArray(colorValuesId);
for (int x = 0; x < colorNames.length; x++) {
Preference preference = new Preference(getContext());
final String name = colorNames[x];
final int color = colorValues.getColor(x, 0);
preference.setOnPreferenceClickListener(p -> {
Intent intent = new Intent();
intent.putExtra("color_name", name);
intent.putExtra("color_value", color);
getActivity().setResult(Activity.RESULT_OK, intent);
getActivity().finish();
return false;
});
preference.setTitle(name);
setStyleIcon(preference, getContext().getDrawable(R.drawable.config_icon).mutate(), color);
getPreferenceScreen().addPreference(preference);
}
colorValues.recycle();
}
示例14: updateServers
import android.preference.Preference; //导入方法依赖的package包/类
private void updateServers()
{
category.removeAll();
List<String> servers = preferences.listServers();
Collections.sort(servers);
for(final String server : servers)
{
Preference preference = new Preference(this);
preference.setTitle(server);
Intent intent = new Intent(this, ServerPreferencesScreen.class);
intent.putExtra("server", server);
preference.setIntent(intent);
category.addPreference(preference);
}
}
示例15: markPro
import android.preference.Preference; //导入方法依赖的package包/类
private void markPro(Preference pref, String sku) {
if (sku == null || !IAB.isPurchased(sku, this)) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean dark = prefs.getBoolean("dark_theme", false);
SpannableStringBuilder ssb = new SpannableStringBuilder(" " + pref.getTitle());
ssb.setSpan(new ImageSpan(this, dark ? R.drawable.ic_shopping_cart_white_24dp : R.drawable.ic_shopping_cart_black_24dp), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
pref.setTitle(ssb);
}
}