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