當前位置: 首頁>>代碼示例>>Java>>正文


Java Preference.setIcon方法代碼示例

本文整理匯總了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()));

        }
    }
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:14,代碼來源:ThemePreference.java

示例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);
        }
    }
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:22,代碼來源:ManagedPreferenceDelegate.java

示例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);
    }
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:23,代碼來源:UsbChooserPreferences.java

示例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);
    }
}
 
開發者ID:Nxt3,項目名稱:IO_Classic_WatchFace,代碼行數:16,代碼來源:SettingsFragment.java

示例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);
    }
}
 
開發者ID:Nxt3,項目名稱:IO_Classic_WatchFace,代碼行數:8,代碼來源:ColorPreferenceFragment.java

示例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);
                }
            }
        }

    }
 
開發者ID:cahergil,項目名稱:Farmacias,代碼行數:38,代碼來源:SettingsFragment.java

示例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);
    }
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:28,代碼來源:InputMethodSettingsImpl.java


注:本文中的android.preference.Preference.setIcon方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。