本文整理汇总了Java中android.support.annotation.AttrRes类的典型用法代码示例。如果您正苦于以下问题:Java AttrRes类的具体用法?Java AttrRes怎么用?Java AttrRes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AttrRes类属于android.support.annotation包,在下文中一共展示了AttrRes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SearchableSpinner
import android.support.annotation.AttrRes; //导入依赖的package包/类
public SearchableSpinner(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
mContext = context;
getAttributeSet(attrs, defStyleAttr, defStyleRes);
final LayoutInflater factory = LayoutInflater.from(context);
factory.inflate(R.layout.view_searchable_spinner, this, true);
mSpinnerListContainer = (LinearLayout) factory.inflate(R.layout.view_list, this, false);
mSpinnerListView = (ListView) mSpinnerListContainer.findViewById(R.id.LstVw_SpinnerListView);
if (mListItemDivider != null) {
mSpinnerListView.setDivider(mListItemDivider);
mSpinnerListView.setDividerHeight(mListDividerSize);
}
mEmptyTextView = (TextView) mSpinnerListContainer.findViewById(R.id.TxtVw_EmptyText);
mSpinnerListView.setEmptyView(mEmptyTextView);
}
示例2: setCryptoMessageSingleLine
import android.support.annotation.AttrRes; //导入依赖的package包/类
private void setCryptoMessageSingleLine(@AttrRes int colorAttr,
@StringRes int topTextRes, @DrawableRes int statusIconRes,
@DrawableRes Integer statusDotsRes) {
@ColorInt int color = ThemeUtils.getStyledColor(getActivity(), colorAttr);
authenticationIcon_1.setImageResource(statusIconRes);
authenticationIcon_1.setColorFilter(color);
authenticationText.setText(topTextRes);
if (statusDotsRes != null) {
authenticationIcon_3.setImageResource(statusDotsRes);
authenticationIcon_3.setColorFilter(color);
authenticationIcon_3.setVisibility(View.VISIBLE);
} else {
authenticationIcon_3.setVisibility(View.GONE);
}
trustText.setVisibility(View.GONE);
trustIconFrame.setVisibility(View.GONE);
}
示例3: getAttributeSet
import android.support.annotation.AttrRes; //导入依赖的package包/类
private void getAttributeSet(@Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
if (attrs != null) {
try {
TypedArray attributes = mContext.getTheme().obtainStyledAttributes(attrs, R.styleable.SearchableSpinner, defStyleAttr, defStyleRes);
mRevealViewBackgroundColor = attributes.getColor(R.styleable.SearchableSpinner_RevealViewBackgroundColor, Color.WHITE);
mStartEditTintColor = attributes.getColor(R.styleable.SearchableSpinner_StartSearchTintColor, Color.GRAY);
mEditViewBackgroundColor = attributes.getColor(R.styleable.SearchableSpinner_SearchViewBackgroundColor, Color.WHITE);
mEditViewTextColor = attributes.getColor(R.styleable.SearchableSpinner_SearchViewTextColor, Color.BLACK);
mDoneEditTintColor = attributes.getColor(R.styleable.SearchableSpinner_DoneSearchTintColor, Color.GRAY);
mBordersSize = attributes.getDimensionPixelSize(R.styleable.SearchableSpinner_BordersSize, 4);
mExpandSize = attributes.getDimensionPixelSize(R.styleable.SearchableSpinner_SpinnerExpandHeight, 0);
mShowBorders = attributes.getBoolean(R.styleable.SearchableSpinner_ShowBorders, false);
mBoarderColor = attributes.getColor(R.styleable.SearchableSpinner_BoarderColor, Color.GRAY);
mAnimDuration = attributes.getColor(R.styleable.SearchableSpinner_AnimDuration, DefaultAnimationDuration);
mKeepLastSearch = attributes.getBoolean(R.styleable.SearchableSpinner_KeepLastSearch, false);
mRevealEmptyText = attributes.getString(R.styleable.SearchableSpinner_RevealEmptyText);
mSearchHintText = attributes.getString(R.styleable.SearchableSpinner_SearchHintText);
mNoItemsFoundText = attributes.getString(R.styleable.SearchableSpinner_NoItemsFoundText);
mListItemDivider = attributes.getDrawable(R.styleable.SearchableSpinner_ItemsDivider);
mListDividerSize = attributes.getDimensionPixelSize(R.styleable.SearchableSpinner_DividerHeight, 0);
} catch (UnsupportedOperationException e) {
Log.e("SearchableSpinner", "getAttributeSet --> " + e.getLocalizedMessage());
}
}
}
示例4: resolveColorStateList
import android.support.annotation.AttrRes; //导入依赖的package包/类
public static ColorStateList resolveColorStateList(Context context, @AttrRes int attr) {
TEMP_ARRAY[0] = attr;
TintTypedArray ta = TintTypedArray.obtainStyledAttributes(context, null, TEMP_ARRAY);
try {
return ta.getColorStateList(0);
} finally {
ta.recycle();
}
}
示例5: resolveResourceId
import android.support.annotation.AttrRes; //导入依赖的package包/类
public static int resolveResourceId(Context context, @AttrRes int attr, int fallback) {
TEMP_ARRAY[0] = attr;
TypedArray ta = context.obtainStyledAttributes(TEMP_ARRAY);
try {
return ta.getResourceId(0, fallback);
} finally {
ta.recycle();
}
}
示例6: getStyleValuesBoolean
import android.support.annotation.AttrRes; //导入依赖的package包/类
public static boolean getStyleValuesBoolean(Context context, @AttrRes int attrId, int style) {
TypedArray a = null;
if (style > 0) {
int[] AttrSet = {attrId};
a = context.obtainStyledAttributes(style, AttrSet);
a.recycle();
}
return a.getBoolean(0, false);
}
示例7: setTransportSecurityMessageSingleLine
import android.support.annotation.AttrRes; //导入依赖的package包/类
private void setTransportSecurityMessageSingleLine(@AttrRes int colorAttr,
@StringRes int topTextRes, @DrawableRes int statusIconRes) {
@ColorInt int color = ThemeUtils.getStyledColor(getActivity(), colorAttr);
transportSecurityIcon_1.setImageResource(statusIconRes);
transportSecurityIcon_1.setColorFilter(color);
transportSecurityText.setText(topTextRes);
}
示例8: getDrawable
import android.support.annotation.AttrRes; //导入依赖的package包/类
/**
* Returns the drawable, which corresponds to a specific theme attribute, regarding the
* theme, which is used when using a specific layout.
*
* @param layout
* The layout as a value of the enum {@link Layout}. The layout may not be null
* @param resourceId
* The resource id of the theme attribute, the drawable should be obtained from, as an
* {@link Integer} value. The resource id must correspond to a valid theme attribute
* @return The color state list, which has been obtained, as an instance of the class {@link
* ColorStateList}
*/
public Drawable getDrawable(@NonNull final Layout layout, @AttrRes final int resourceId) {
try {
return ThemeUtil.getDrawable(context, resourceId);
} catch (NotFoundException e1) {
int themeResourceId = getThemeResourceId(layout);
try {
return ThemeUtil.getDrawable(context, themeResourceId, resourceId);
} catch (NotFoundException e) {
themeResourceId = obtainThemeFromThemeAttributes(layout, themeResourceId);
return ThemeUtil.getDrawable(context, themeResourceId, resourceId);
}
}
}
示例9: setDKIMMessageSingleLine
import android.support.annotation.AttrRes; //导入依赖的package包/类
private void setDKIMMessageSingleLine(@AttrRes int colorAttr,
@StringRes int topTextRes, @DrawableRes int statusIconRes) {
@ColorInt int color = ThemeUtils.getStyledColor(getActivity(), colorAttr);
dkimIcon_1.setImageResource(statusIconRes);
dkimIcon_1.setColorFilter(color);
dkimText.setText(topTextRes);
}
示例10: getAttributeColor
import android.support.annotation.AttrRes; //导入依赖的package包/类
@ColorInt
public static int getAttributeColor(Context context, @AttrRes int attr, int fallback)
{
TypedArray a = context.getTheme().obtainStyledAttributes(new int[] {attr});
try
{
return a.getColor(0, fallback);
}
finally
{
a.recycle();
}
}
示例11: getColorFromAttr
import android.support.annotation.AttrRes; //导入依赖的package包/类
/**
* Get color attribute from current theme
*
* @param context Themed context
* @param attr The resource id of color attribute
* @return Result
*/
@ColorInt
static int getColorFromAttr(Context context, @AttrRes int attr) {
TypedArray array = context.getTheme().obtainStyledAttributes(new int[]{attr});
int color = array.getColor(0, Color.TRANSPARENT);
array.recycle();
return color;
}
示例12: resolveDrawable
import android.support.annotation.AttrRes; //导入依赖的package包/类
private static Drawable resolveDrawable(Context context,
@AttrRes int attr,
@SuppressWarnings(
"SameParameterValue") Drawable fallback) {
TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr});
try {
Drawable d = a.getDrawable(0);
if (d == null && fallback != null)
d = fallback;
return d;
} finally {
a.recycle();
}
}
示例13: getColor
import android.support.annotation.AttrRes; //导入依赖的package包/类
static int getColor(Context context, @AttrRes int attr, int defaultColor) {
TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr});
try {
return a.getColor(0, defaultColor);
} finally {
a.recycle();
}
}
示例14: SCCameraView
import android.support.annotation.AttrRes; //导入依赖的package包/类
public SCCameraView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
super(context, attrs, defStyleAttr);
if (isInEditMode()){
cameraView = null;
return;
}
cameraView = BaseCameraView.createCameraView(context);
cameraView.loadAspectRatios();
this.addView(cameraView);
}
示例15: getThemeAttrBoolean
import android.support.annotation.AttrRes; //导入依赖的package包/类
public static boolean getThemeAttrBoolean(Context context, @AttrRes int attr) {
TEMP_ARRAY[0] = attr;
TypedArray a = context.obtainStyledAttributes(null, TEMP_ARRAY);
try {
return a.getBoolean(0, false);
} finally {
a.recycle();
}
}