本文整理汇总了Java中android.preference.Preference.setIcon方法的典型用法代码示例。如果您正苦于以下问题:Java Preference.setIcon方法的具体用法?Java Preference.setIcon怎么用?Java Preference.setIcon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.preference.Preference
的用法示例。
在下文中一共展示了Preference.setIcon方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCircularPreferenceBitmap
import android.preference.Preference; //导入方法依赖的package包/类
public static void createCircularPreferenceBitmap(Boolean isImage, Preference preference, ImageView imageView, Context context, int color) {
Bitmap.Config conf = Bitmap.Config.ARGB_8888;
int dimen = (int) context.getResources().getDimension(android.R.dimen.app_icon_size);
Bitmap bmp = Bitmap.createBitmap(dimen, dimen, conf);
if (isImage) {
imageView.setBackground(createRoundedBitmapDrawable(bmp, color, context.getResources()));
} else {
preference.setIcon(createRoundedBitmapDrawable(bmp, color, context.getResources()));
}
}
示例2: initPreference
import android.preference.Preference; //导入方法依赖的package包/类
/**
* Initializes the Preference based on the state of any policies that may affect it,
* e.g. by showing a managed icon or disabling clicks on the preference.
*
* This should be called once, before the preference is displayed.
*/
public void initPreference(Preference preference) {
if (isPreferenceControlledByPolicy(preference)) {
preference.setIcon(ManagedPreferencesUtils.getManagedByEnterpriseIconId());
if (isPreferenceClickDisabledByPolicy(preference)) {
// Disable the views and prevent the Preference from mucking with the enabled state.
preference.setShouldDisableView(false);
// Prevent default click behavior.
preference.setFragment(null);
preference.setIntent(null);
preference.setOnPreferenceClickListener(null);
}
}
}
示例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: setStyleIcon
import android.preference.Preference; //导入方法依赖的package包/类
/**
* Sets the icon styles for the preferences
*
* @param preference belonging to the icon
* @param icon to set the styles of
*/
private void setStyleIcon(Preference preference, Drawable icon) {
final LayerDrawable layerDrawable
= (LayerDrawable) mContext.getDrawable(R.drawable.config_icon);
icon.setTint(Color.WHITE);
if (layerDrawable != null && layerDrawable.setDrawableByLayerId(R.id.nested_icon, icon)) {
preference.setIcon(layerDrawable);
}
}
示例5: setStyleIcon
import android.preference.Preference; //导入方法依赖的package包/类
private void setStyleIcon(Preference preference, Drawable icon, int color) {
LayerDrawable layerDrawable = (LayerDrawable) getContext().getDrawable(R.drawable.config_icon);
icon.setTint(color);
if (layerDrawable != null && layerDrawable.setDrawableByLayerId(R.id.nested_icon, icon)) {
preference.setIcon(layerDrawable);
}
}
示例6: bindPreferenceSummaryToValue
import android.preference.Preference; //导入方法依赖的package包/类
private void bindPreferenceSummaryToValue(Preference preference) {
// Set the listener to watch for value changes.
preference.setOnPreferenceChangeListener(this);
preference.setOnPreferenceClickListener(this);
if (preference instanceof CheckBoxPreference) {
onPreferenceChange(preference,
PreferenceManager
.getDefaultSharedPreferences(preference.getContext())
.getBoolean(preference.getKey(), false));
} else if (preference instanceof SeekBarPreference) {
// Trigger the listener immediately with the preference's
// current value.
onPreferenceChange(preference,
PreferenceManager
.getDefaultSharedPreferences(preference.getContext())
.getInt(preference.getKey(), 0));
} else {
onPreferenceChange(preference,
PreferenceManager
.getDefaultSharedPreferences(preference.getContext())
.getString(preference.getKey(), ""));
if (preference instanceof Preference) {
Preference pref = (Preference) preference;
//scale the vector drawable R.drawable.google_play to 24f
if (getString(R.string.pref_rate_key).equals(pref.getKey())) {
// VectorDrawableCompat drawable = VectorDrawableCompat.create(getActivity().getApplicationContext().getResources(),
// R.drawable.google_play, null);
// Bitmap bitmap = Utils.createScaledBitMapFromVectorDrawable(getActivity().getApplicationContext(), drawable, 24f);
// Drawable rateIcon = new BitmapDrawable(getResources(), bitmap);
// pref.setIcon(rateIcon);
pref.setIcon(R.drawable.google_play);
}
}
}
}
示例7: 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);
}
}