本文整理汇总了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);
}
示例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();
}
}
});
}
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
}
示例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();
}
}