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


Java AppCompatResources類代碼示例

本文整理匯總了Java中android.support.v7.content.res.AppCompatResources的典型用法代碼示例。如果您正苦於以下問題:Java AppCompatResources類的具體用法?Java AppCompatResources怎麽用?Java AppCompatResources使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AppCompatResources類屬於android.support.v7.content.res包,在下文中一共展示了AppCompatResources類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: selectedBank

import android.support.v7.content.res.AppCompatResources; //導入依賴的package包/類
private void selectedBank(final GiroPayIssuer bank) {
    editText.removeTextChangedListener(giroPayTextWatcher);
    editText.setText(bank.getBankName());
    editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
    editText.setSingleLine(false);
    editText.clearFocus();
    editText.setEnabled(false);
    editText.setCancelDrawable(AppCompatResources.getDrawable(getContext(), R.drawable.clear_icon),
            new GiroPayEditText.OnDrawableClickListener() {
        @Override
        public void onDrawableClick() {
            unSelectedBank();
        }
    });

    issuerListAdapter.clearData();
    issuerListAdapter.notifyDataSetChanged();

    InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(editText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);

    payButton.setEnabled(true);
}
 
開發者ID:Adyen,項目名稱:adyen-android,代碼行數:24,代碼來源:GiropayFragment.java

示例2: setDataBindingVariables

import android.support.v7.content.res.AppCompatResources; //導入依賴的package包/類
@Override protected void setDataBindingVariables(ViewDataBinding binding) {

    if (binding instanceof LayoutScatterChartBinding) {

      Drawable drawable = AppCompatResources.getDrawable(binding.getRoot().getContext(),
                                                         R.drawable.shape_circle);
      scatterDataSet.setShape(drawable);

      LayoutScatterChartBinding bd = (LayoutScatterChartBinding) binding;

      bd.combineChart.getAxisBottom().setGridCount(1);
      bd.combineChart.getAxisLeft().setGridCount(1);
      bd.combineChart.addDataSet(scatterDataSet);

      bd.combineChart.setOnEntryClickListener(new OnEntryClickListener() {
        @Override public void onEntryClick(Chart chart, int position) {
          if (position >= 0) {
            Toast.makeText(chart.getContext(), textList.get(position), Toast.LENGTH_SHORT).show();
          }
        }
      });
    }

  }
 
開發者ID:donglua,項目名稱:JZAndroidChart,代碼行數:25,代碼來源:ScatterChart2Model.java

示例3: inflateButton

import android.support.v7.content.res.AppCompatResources; //導入依賴的package包/類
private View inflateButton(final Context context, @DrawableRes final int icon, final ViewGroup parent) {
    final View categoryView = LayoutInflater.from(context).inflate(R.layout.emoji_category, parent, false);
    final RelativeLayout categoryLayout = (RelativeLayout) categoryView.findViewById(R.id.category_layout);
    final ImageView categoryIcon = (ImageView) categoryView.findViewById(R.id.category_button);

    categoryIcon.setImageDrawable(AppCompatResources.getDrawable(context, icon));
    categoryIcon.setColorFilter(themeIconColor, PorterDuff.Mode.SRC_IN);

    if (icon == R.drawable.emoji_backspace) {
        categoryLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.emoji_backspace_background));
    }

    parent.addView(categoryView);

    return categoryView;
}
 
開發者ID:apradanas,項目名稱:prismoji-android,代碼行數:17,代碼來源:PrismojiView.java

示例4: toggleRadialPickerMode

import android.support.v7.content.res.AppCompatResources; //導入依賴的package包/類
private void toggleRadialPickerMode() {
    if (mRadialPickerModeEnabled) {
        mRadialTimePickerView.setVisibility(View.GONE);
        mRadialTimePickerHeader.setVisibility(View.GONE);
        mTextInputPickerHeader.setVisibility(View.VISIBLE);
        mTextInputPickerView.setVisibility(View.VISIBLE);
        //mRadialTimePickerModeButton.setImageResource(R.drawable.btn_clock_material);
        mRadialTimePickerModeButton.setImageDrawable(Utils.tintDrawable(mContext, AppCompatResources.getDrawable(mContext, R.drawable.btn_clock_material), R.attr.colorControlNormal)); // fixing tinting
        mRadialTimePickerModeButton.setContentDescription(
                mRadialTimePickerModeEnabledDescription);
        mRadialPickerModeEnabled = false;
    } else {
        mRadialTimePickerView.setVisibility(View.VISIBLE);
        mRadialTimePickerHeader.setVisibility(View.VISIBLE);
        mTextInputPickerHeader.setVisibility(View.GONE);
        mTextInputPickerView.changeInputMethod(false);
        mTextInputPickerView.setVisibility(View.GONE);
        //mRadialTimePickerModeButton.setImageResource(R.drawable.btn_keyboard_key_material);
        mRadialTimePickerModeButton.setImageDrawable(Utils.tintDrawable(mContext, AppCompatResources.getDrawable(mContext, R.drawable.btn_keyboard_key_material), R.attr.colorControlNormal)); // fixing tinting
        mRadialTimePickerModeButton.setContentDescription(
                mTextInputPickerModeEnabledDescription);
        updateTextInputPicker();
        mRadialPickerModeEnabled = true;
    }
}
 
開發者ID:Gericop,項目名稱:DateTimePicker,代碼行數:26,代碼來源:TimePickerClockDelegate.java

示例5: getBitmapFromVectorDrawable

import android.support.v7.content.res.AppCompatResources; //導入依賴的package包/類
/**
 * Converts a vector asset to a bitmap as required by {@link CustomTabsIntent.Builder#setCloseButtonIcon(Bitmap)}
 *
 * @param drawableId The drawable ID
 * @return Bitmap equivalent
 */
private Bitmap getBitmapFromVectorDrawable(final @DrawableRes int drawableId) {
    Drawable drawable = AppCompatResources.getDrawable(this, drawableId);
    if (drawable == null) {
        return null;
    }
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        drawable = (DrawableCompat.wrap(drawable)).mutate();
    }

    Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
            drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);

    return bitmap;
}
 
開發者ID:saschpe,項目名稱:android-customtabs,代碼行數:24,代碼來源:MainActivity.java

示例6: instantiateItem

import android.support.v7.content.res.AppCompatResources; //導入依賴的package包/類
@Override
public Object instantiateItem(ViewGroup container, int position) {
    Context context = container.getContext();
    LayoutInflater inflater = LayoutInflater.from(context);
    ImageView imageView = (ImageView) inflater.inflate(R.layout.pagerimage, container, false);
    container.addView(imageView);
    if (mFallback == null) {
        mFallback = AppCompatResources.getDrawable(context, mFallbackId);
    }
    Picasso.with(context)
            .load(mImageUrls.get(position))
            .error(mFallback)
            .placeholder(mFallback)
            .fit()
            .centerCrop()
            .into(imageView);
    return imageView;
}
 
開發者ID:Turistforeningen,項目名稱:SjekkUT,代碼行數:19,代碼來源:ImageAdapter.java

示例7: repopulateNavigation

import android.support.v7.content.res.AppCompatResources; //導入依賴的package包/類
public void repopulateNavigation(BinInformation[] bins) {
    Menu menu = mNavigationView.getMenu();
    menu.clear();
    mNavigationView.inflateMenu(R.menu.menu_activity_main_bins);
    for(BinInformation bin : bins) {
        MenuItem menuItem = menu.add(
                R.id.group_bins,
                bin.getId(),
                0,
                MessageFormat.format(
                        "Bin {0}: {1}%",
                        Integer.toString(bin.getId()),
                        Integer.toString(bin.full)
                )
        );
        Drawable drawable = AppCompatResources.getDrawable(this, R.drawable.ic_marker);
        drawable = drawable.mutate();
        drawable.setColorFilter(getBlendedColour(bin.full), PorterDuff.Mode.SRC_IN);
        menuItem.setIcon(drawable);
    }
}
 
開發者ID:PatrickShaw,項目名稱:SpotlessGHack-Intellibins-Android,代碼行數:22,代碼來源:MapsActivity.java

示例8: getDrawable

import android.support.v7.content.res.AppCompatResources; //導入依賴的package包/類
public static Drawable getDrawable(Context context, @Nullable Feed feed) {
    Drawable drawable;

    if(feed != null && feed.getFaviconLink() == null) {
        drawable = faviconCache.get(feed.getId());

        if(drawable == null) {
            drawable = new TextDrawable.Builder(feed.getName().length() > 0 ? feed.getName().substring(0, 1) : "?", getFeedColor(context, feed))
                    .textColor(ContextCompat.getColor(context, R.color.textdrawable_text))
                    .build();
            faviconCache.put(feed.getId(), drawable);
        }
    } else {
        drawable = AppCompatResources.getDrawable(context, R.drawable.ic_feed_icon);
    }
    return drawable;
}
 
開發者ID:schaal,項目名稱:ocreader,代碼行數:18,代碼來源:FaviconLoader.java

示例9: apply

import android.support.v7.content.res.AppCompatResources; //導入依賴的package包/類
@Override
public void apply(View view, String resName) {
    if (TextUtils.isEmpty(resName)) return;
    if (view instanceof ImageView) {
        Drawable drawable;
        if (((ImageView) view).getDrawable() != null
                && ((ImageView) view).getDrawable().getClass().getName().toLowerCase().contains("vector")) {
            int resId = view.getResources().getIdentifier(resName, DEFTYPE_DRAWABLE, view.getContext().getPackageName());
            drawable = AppCompatResources.getDrawable(view.getContext(), resId);
        } else {
            drawable = getDrawable(view.getContext(), resName);
        }
        if (drawable == null) return;
        ((ImageView) view).setImageDrawable(drawable);
    }
}
 
開發者ID:achenglike,項目名稱:NightModel,代碼行數:17,代碼來源:AttrTypeImageSrcCompat.java

示例10: AutofillPaymentInstrument

import android.support.v7.content.res.AppCompatResources; //導入依賴的package包/類
/**
 * Builds a payment instrument for the given credit card.
 *
 * @param webContents    The web contents where PaymentRequest was invoked.
 * @param card           The autofill card that can be used for payment.
 * @param billingAddress The billing address for the card.
 * @param methodName     The payment method name, e.g., "basic-card", "visa", amex", or null.
 */
public AutofillPaymentInstrument(WebContents webContents, CreditCard card,
        @Nullable AutofillProfile billingAddress, @Nullable String methodName) {
    super(card.getGUID(), card.getObfuscatedNumber(), card.getName(), null);
    mWebContents = webContents;
    mCard = card;
    mBillingAddress = billingAddress;
    mIsEditable = true;
    mMethodName = methodName;

    Context context = ChromeActivity.fromWebContents(mWebContents);
    if (context == null) return;

    if (card.getIssuerIconDrawableId() != 0) {
        updateDrawableIcon(
                AppCompatResources.getDrawable(context, card.getIssuerIconDrawableId()));
    }

    checkAndUpateCardCompleteness(context);
}
 
開發者ID:mogoweb,項目名稱:365browser,代碼行數:28,代碼來源:AutofillPaymentInstrument.java

示例11: bind

import android.support.v7.content.res.AppCompatResources; //導入依賴的package包/類
void bind(Tag filter, boolean checked) {
    mTagFilter = filter;

    mLabel.setText(filter.getName());
    mCheckbox.setContentDescription(mLabel.getText());
    setChecked(checked);
    if (filter.getId().startsWith(Tags.CATEGORY_TRACK)) {
        if (mLabel.getBackground() == null) {
            mLabel.setBackground(AppCompatResources.getDrawable(mLabel.getContext(),
                    R.drawable.tag_session_background));
        }
        ViewCompat.setBackgroundTintList(mLabel, ColorStateList.valueOf(filter.getColor()));
    } else {
        mLabel.setBackground(null);
    }
}
 
開發者ID:google,項目名稱:iosched,代碼行數:17,代碼來源:SessionsFilterAdapter.java

示例12: getView

import android.support.v7.content.res.AppCompatResources; //導入依賴的package包/類
@Override
public View getView(int position, View convertView, ViewGroup parent) {
	if (convertView == null) {
		convertView = inflater.inflate(R.layout.item_main_menu, parent, false);
		convertView.setOnClickListener(sectionClickListener);
	}

	Section section = getItem(position);
	convertView.setSelected(section == currentSection);

	TextView tv = convertView.findViewById(R.id.section_text);
	SpannableString sectionTitle = new SpannableString(getString(section.getTitleResId()));
	Drawable sectionIcon = AppCompatResources.getDrawable(MainActivity.this, section.getIconResId());
	if (section == currentSection) {
		// Special color for the current section
		sectionTitle.setSpan(new ForegroundColorSpan(currentSectionForegroundColor), 0, sectionTitle.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
		// We need to mutate the drawable before applying the ColorFilter, or else all the similar drawable instances will be tinted.
		sectionIcon.mutate().setColorFilter(currentSectionForegroundColor, PorterDuff.Mode.SRC_IN);
	}
	tv.setText(sectionTitle);
	TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(tv, sectionIcon, null, null, null);

	return convertView;
}
 
開發者ID:cbeyls,項目名稱:fosdem-companion-android,代碼行數:25,代碼來源:MainActivity.java

示例13: onBindViewHolder

import android.support.v7.content.res.AppCompatResources; //導入依賴的package包/類
@Override
public void onBindViewHolder(ViewHolder holder, Cursor cursor) {
	Context context = holder.itemView.getContext();
	Event event = DatabaseManager.toEvent(cursor, holder.event);
	holder.event = event;

	holder.title.setText(event.getTitle());
	boolean isBookmarked = DatabaseManager.toBookmarkStatus(cursor);
	Drawable bookmarkDrawable = isBookmarked
			? AppCompatResources.getDrawable(context, R.drawable.ic_bookmark_grey600_24dp)
			: null;
	TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(holder.title, null, null, bookmarkDrawable, null);
	holder.title.setContentDescription(isBookmarked
			? context.getString(R.string.in_bookmarks_content_description, event.getTitle())
			: null
	);
	String personsSummary = event.getPersonsSummary();
	holder.persons.setText(personsSummary);
	holder.persons.setVisibility(TextUtils.isEmpty(personsSummary) ? View.GONE : View.VISIBLE);
	Track track = event.getTrack();
	holder.trackName.setText(track.getName());
	holder.trackName.setTextColor(ContextCompat.getColor(context, track.getType().getColorResId()));
	holder.trackName.setContentDescription(context.getString(R.string.track_content_description, track.getName()));

	bindDetails(holder, event);
}
 
開發者ID:cbeyls,項目名稱:fosdem-companion-android,代碼行數:27,代碼來源:EventsAdapter.java

示例14: loadDrawableV7

import android.support.v7.content.res.AppCompatResources; //導入依賴的package包/類
/**
 * Tries to load the drawable thanks to AppCompatResources.<br>
 * This allows to parse VectorDrawables on legacy devices if the appcompat v7 is in the classpath.
 */
private Drawable loadDrawableV7(@DrawableRes int resourceId) {
  try {
    return AppCompatResources.getDrawable(glideContext, resourceId);
  } catch (NoClassDefFoundError error) {
    shouldCallAppCompatResources = false;
    return loadDrawableBase(resourceId);
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:SingleRequest.java

示例15: applyAttrs

import android.support.v7.content.res.AppCompatResources; //導入依賴的package包/類
private void applyAttrs(final AttributeSet attrs) {

        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ListItemView);

        try {

            mMenuId = a.getResourceId(R.styleable.ListItemView_liv_menu, NULL);
            mMenuItemsRoom = a.getInteger(R.styleable.ListItemView_liv_menuItemsRoom,
                    DEFAULT_MENU_ITEMS_ROOM);
            mMenuActionColor = a.getColor(R.styleable.ListItemView_liv_menuActionColor,
                    Color.TRANSPARENT);
            mMenuOverflowColor = a.getColor(R.styleable.ListItemView_liv_menuOverflowColor,
                    Color.TRANSPARENT);

            mTitle = a.getString(R.styleable.ListItemView_liv_title);
            mSubtitle = a.getString(R.styleable.ListItemView_liv_subtitle);
            mIsMultiline = a.getBoolean(R.styleable.ListItemView_liv_multiline, false);
            mDisplayMode = a.getInt(R.styleable.ListItemView_liv_displayMode, mDisplayMode);

            mPaddingEnd = a.getDimensionPixelSize(R.styleable.ListItemView_liv_paddingEnd,
                    mPaddingEnd);
            mPaddingStart = a.getDimensionPixelSize(R.styleable.ListItemView_liv_paddingStart,
                    mPaddingStart);
            mKeyline = a.getDimensionPixelSize(R.styleable.ListItemView_liv_keyline, mKeyline);
            mForceKeyline = a.getBoolean(R.styleable.ListItemView_liv_forceKeyline, false);

            int iconDrawableResId = a.getResourceId(R.styleable.ListItemView_liv_icon, NULL);
            if (iconDrawableResId != NULL) {
                mIconDrawable = AppCompatResources.getDrawable(getContext(), iconDrawableResId);
            }

            mIconColor = a.getColor(R.styleable.ListItemView_liv_iconColor, Color.TRANSPARENT);
            mCircularIconColor = a.getColor(R.styleable.ListItemView_liv_circularIconColor,
                    Color.TRANSPARENT);

        } finally {
            a.recycle();
        }
    }
 
開發者ID:lurbas,項目名稱:ListItemView,代碼行數:40,代碼來源:ListItemView.java


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