本文整理汇总了Java中android.content.res.TypedArray.getResourceId方法的典型用法代码示例。如果您正苦于以下问题:Java TypedArray.getResourceId方法的具体用法?Java TypedArray.getResourceId怎么用?Java TypedArray.getResourceId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.res.TypedArray
的用法示例。
在下文中一共展示了TypedArray.getResourceId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RelativeRadioGroup
import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public RelativeRadioGroup(Context context, AttributeSet attrs) {
super(context, attrs);
// retrieve selected radio button as requested by the user in the
// XML layout file
TypedArray attributes = context.obtainStyledAttributes(
attrs, R.styleable.RelativeRadioGroup, 0, 0);
int value = attributes.getResourceId(R.styleable.RelativeRadioGroup_checkedButton, View.NO_ID);
if (value != View.NO_ID) {
mCheckedId = value;
}
attributes.recycle();
init();
}
示例2: obtainAttributes
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void obtainAttributes(Context context, AttributeSet attrs) {
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SegmentTabLayout);
mIndicatorColorResId = ta.getResourceId(R.styleable.SegmentTabLayout_tl_indicator_color, INVALID_ID);
mIndicatorColorResId = SkinCompatHelper.checkResourceId(mIndicatorColorResId);
mDividerColorResId = ta.getResourceId(R.styleable.SegmentTabLayout_tl_divider_color, mIndicatorColorResId);
mDividerColorResId = SkinCompatHelper.checkResourceId(mDividerColorResId);
mTextSelectColorResId = ta.getResourceId(R.styleable.SegmentTabLayout_tl_textSelectColor, INVALID_ID);
mTextSelectColorResId = SkinCompatHelper.checkResourceId(mTextSelectColorResId);
mTextUnselectColorResId = ta.getResourceId(R.styleable.SegmentTabLayout_tl_textUnselectColor, mIndicatorColorResId);
mTextUnselectColorResId = SkinCompatHelper.checkResourceId(mTextUnselectColorResId);
mBarColorResId = ta.getResourceId(R.styleable.SegmentTabLayout_tl_bar_color, INVALID_ID);
mBarColorResId = SkinCompatHelper.checkResourceId(mBarColorResId);
mBarStrokeColorResId = ta.getResourceId(R.styleable.SegmentTabLayout_tl_bar_stroke_color, mIndicatorColorResId);
mBarStrokeColorResId = SkinCompatHelper.checkResourceId(mBarStrokeColorResId);
ta.recycle();
applySegmentTabLayoutResources();
}
示例3: initAttrs
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void initAttrs(AttributeSet attrs, int defStyle) {
TypedArray a = getContext().getTheme().obtainStyledAttributes(
attrs, R.styleable.ColorPreference, defStyle, defStyle);
try {
mItemLayoutId = a.getResourceId(R.styleable.ColorPreference_itemLayout, mItemLayoutId);
mNumColumns = a.getInteger(R.styleable.ColorPreference_numColumns, mNumColumns);
int choicesResId = a.getResourceId(R.styleable.ColorPreference_choices,
R.array.default_color_choice_values);
if (choicesResId > 0) {
String[] choices = a.getResources().getStringArray(choicesResId);
mColorChoices = new int[choices.length];
for (int i = 0; i < choices.length; i++) {
mColorChoices[i] = Color.parseColor(choices[i]);
}
}
} finally {
a.recycle();
}
setWidgetLayoutResource(mItemLayoutId);
}
示例4: SwipeBackLayout
import android.content.res.TypedArray; //导入方法依赖的package包/类
public SwipeBackLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs);
mDragHelper = ViewDragHelper.create(this, new ViewDragCallback());
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SwipeBackLayout, defStyle,
R.style.SwipeBackLayout);
int mode = EDGE_FLAGS[a.getInt(R.styleable.SwipeBackLayout_edge_flag, 0)];
setEdgeTrackingEnabled(mode);
int shadowLeft = a.getResourceId(R.styleable.SwipeBackLayout_shadow_left,
R.drawable.shadow_left);
int shadowRight = a.getResourceId(R.styleable.SwipeBackLayout_shadow_right,
R.drawable.shadow_right);
int shadowBottom = a.getResourceId(R.styleable.SwipeBackLayout_shadow_bottom,
R.drawable.shadow_bottom);
setShadow(shadowLeft, EDGE_LEFT);
setShadow(shadowRight, EDGE_RIGHT);
setShadow(shadowBottom, EDGE_BOTTOM);
a.recycle();
final float density = getResources().getDisplayMetrics().density;
final float minVel = MIN_FLING_VELOCITY * density;
mDragHelper.setMinVelocity(minVel);
}
示例5: initialize
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void initialize(@Nullable AttributeSet attrs) {
if (attrs != null) {
TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.PagerContainer);
viewPagerId = typedArray.getResourceId(R.styleable.PagerContainer_viewPager, PAGER_ID_NONE);
typedArray.recycle();
}
/**
* Necessary to show views outside of the viewpager's frame.
*/
setClipChildren(false);
/**
* Child clipping doesn't work with hardware acceleration in Android 3.x/4.x You need to
* set this value here if using hardware acceleration in an application targeted at these
* releases.
*/
if (Build.VERSION.SDK_INT < 19) {
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
}
示例6: SwipeBackLayout
import android.content.res.TypedArray; //导入方法依赖的package包/类
public SwipeBackLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs);
mDragHelper = ViewDragHelper.create(this, new ViewDragCallback());
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SwipeBackLayout, defStyle,
R.style.SwipeBackLayout);
int edgeSize = a.getDimensionPixelSize(R.styleable.SwipeBackLayout_edge_size, -1);
if (edgeSize > 0) setEdgeSize(edgeSize);
int mode = EDGE_FLAGS[a.getInt(R.styleable.SwipeBackLayout_edge_flag, 0)];
setEdgeTrackingEnabled(mode);
int shadowLeft =
a.getResourceId(R.styleable.SwipeBackLayout_shadow_left, R.drawable.shadow_left);
int shadowRight =
a.getResourceId(R.styleable.SwipeBackLayout_shadow_right, R.drawable.shadow_right);
int shadowBottom = a.getResourceId(R.styleable.SwipeBackLayout_shadow_bottom,
R.drawable.shadow_bottom);
int shadowTop =
a.getResourceId(R.styleable.SwipeBackLayout_shadow_top, R.drawable.shadow_top);
setShadow(shadowLeft, EDGE_LEFT);
setShadow(shadowRight, EDGE_RIGHT);
setShadow(shadowBottom, EDGE_BOTTOM);
setShadow(shadowTop, EDGE_TOP);
a.recycle();
final float density = getResources().getDisplayMetrics().density;
final float minVel = MIN_FLING_VELOCITY * density;
mDragHelper.setMinVelocity(minVel);
mDragHelper.setMaxVelocity(minVel * 2f);
}
示例7: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
* Called from one of constructors of this view to perform its initialization.
* <p>
* Initialization is done via parsing of the specified <var>attrs</var> set and obtaining for
* this view specific data from it that can be used to configure this new view instance. The
* specified <var>defStyleAttr</var> and <var>defStyleRes</var> are used to obtain default data
* from the current theme provided by the specified <var>context</var>.
*/
@SuppressWarnings("ConstantConditions")
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
if (!isInEditMode()) {
final Resources.Theme theme = context.getTheme();
// Try to apply font presented within text appearance style.
final TypedArray appearanceAttributes = theme.obtainStyledAttributes(attrs, new int[]{android.R.attr.textAppearance}, defStyleAttr, defStyleRes);
final int appearance = appearanceAttributes.getResourceId(0, -1);
if (appearance != -1) {
FontApplier.DEFAULT.applyFont(this, appearance);
}
appearanceAttributes.recycle();
// Try to apply font presented within xml attributes.
FontApplier.DEFAULT.applyFont(this, attrs, defStyleAttr, defStyleRes);
}
// Default set up.
this.mLocale = Locale.getDefault();
this.handleLocaleChange();
final TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.Ui_MonthView, defStyleAttr, defStyleRes);
this.processTintValues(context, attributes);
for (int i = 0; i < attributes.getIndexCount(); i++) {
final int index = attributes.getIndex(i);
if (index == R.styleable.Ui_MonthView_android_horizontalSpacing) {
this.mSpacingHorizontal = attributes.getDimensionPixelSize(index, mSpacingHorizontal);
} else if (index == R.styleable.Ui_MonthView_android_verticalSpacing) {
this.mSpacingVertical = attributes.getDimensionPixelSize(index, mSpacingVertical);
} else if (index == R.styleable.Ui_MonthView_uiMonthDayLettersOffsetVertical) {
this.mDayLettersOffsetVertical = attributes.getDimensionPixelSize(index, mDayLettersOffsetVertical);
} else if (index == R.styleable.Ui_MonthView_uiMonthDayNumbersOffsetVertical) {
this.mDayNumbersOffsetVertical = attributes.getDimensionPixelOffset(index, mDayNumbersOffsetVertical);
} else if (index == R.styleable.Ui_MonthView_uiMonthTitleTextAppearance) {
setTitleTextAppearance(attributes.getResourceId(index, 0));
} else if (index == R.styleable.Ui_MonthView_uiMonthDayLetterTextAppearance) {
setDayLetterTextAppearance(attributes.getResourceId(index, 0));
} else if (index == R.styleable.Ui_MonthView_uiMonthDayNumberTextAppearance) {
setDayNumberTextAppearance(attributes.getResourceId(index, 0));
} else if (index == R.styleable.Ui_MonthView_uiMonthDaySelector) {
setDaySelector(attributes.getResourceId(index, 0));
} else if (index == R.styleable.Ui_MonthView_uiMonthDaySelectorRadius) {
setDaySelectorRadius(attributes.getDimensionPixelSize(index, mDaySelectorRadius));
} else if (index == R.styleable.Ui_MonthView_uiMonthCurrentDayTextColor) {
setCurrentDayTextColor(attributes.getColorStateList(index));
}
}
attributes.recycle();
this.applyDaySelectorTint();
}
示例8: BottomNavigationBehavior
import android.content.res.TypedArray; //导入方法依赖的package包/类
public BottomNavigationBehavior(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs,
attrsArray);
mTabLayoutId = a.getResourceId(0, View.NO_ID);
mElevation = a.getResourceId(1, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mElevation, context.getResources().getDisplayMetrics()));
a.recycle();
}
示例9: loadErrorTextColorResFromAttributes
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void loadErrorTextColorResFromAttributes(@StyleRes int resId) {
if (resId != INVALID_ID) {
TypedArray errorTA = getContext().obtainStyledAttributes(resId, skin.support.R.styleable.SkinTextAppearance);
if (errorTA.hasValue(skin.support.R.styleable.SkinTextAppearance_android_textColor)) {
mErrorTextColorResId = errorTA.getResourceId(skin.support.R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
}
errorTA.recycle();
}
applyErrorTextColorResource();
}
示例10: GradientButton
import android.content.res.TypedArray; //导入方法依赖的package包/类
public GradientButton(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
setDefaultRippleColor(context);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.GradientButton);
isFilled = a.getBoolean(R.styleable.GradientButton_filled, false);
isCircular = a.getBoolean(R.styleable.GradientButton_circular, false);
mStroke = a.getDimensionPixelSize(R.styleable.GradientButton_stroke, 0);
mBackgroundColor = a.getColor(R.styleable.GradientButton_fill_color, Color.TRANSPARENT);
@Orientation
int orientation = a.getInt(R.styleable.GradientButton_orientation, TOP_BOTTOM);
mOrientation = orientation;
if(a.hasValue(R.styleable.GradientButton_gradient)) {
final int id = a.getResourceId(R.styleable.GradientButton_gradient, 0);
int[] values = getResources().getIntArray(id);
mGradient = new int[values.length];
for(int i = 0; i < values.length; i++) {
mGradient[i] = ContextCompat.getColor(context, values[i]);
}
} else {
mGradient = new int[] {
a.getColor(R.styleable.GradientButton_start_color, Color.BLUE),
a.getColor(R.styleable.GradientButton_end_color, Color.GREEN)
};
}
a.recycle();
}
示例11: CapitalizingButton
import android.content.res.TypedArray; //导入方法依赖的package包/类
public CapitalizingButton(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs, R_styleable_Button);
int ap = a.getResourceId(R_styleable_Button_textAppearance, -1);
a.recycle();
if (ap != -1) {
TypedArray appearance = context.obtainStyledAttributes(ap, R_styleable_TextAppearance);
if (appearance != null) {
mAllCaps = appearance.getBoolean(R_styleable_TextAppearance_textAllCaps, true);
appearance.recycle();
}
}
}
示例12: getClickBg
import android.content.res.TypedArray; //导入方法依赖的package包/类
private int getClickBg() {
TypedArray typedArray = obtainStyledAttributes(new int[] {Build.VERSION.SDK_INT >= 21
? android.R.attr.selectableItemBackgroundBorderless
: android.R.attr.selectableItemBackground
});
int resId = typedArray.getResourceId(0, 0);
typedArray.recycle();
return resId;
}
示例13: PictureProgressBar
import android.content.res.TypedArray; //导入方法依赖的package包/类
public PictureProgressBar(Context context, AttributeSet attrs) throws Exception {
super(context, attrs);
//获取xml属性
TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.PictureProgressBar, 0, 0);
backGroundColor = typedArray.getColor(R.styleable.PictureProgressBar_backGroundColor, Color.GRAY);
barColor = typedArray.getColor(R.styleable.PictureProgressBar_barColor, Color.RED);
drawable = typedArray.getDrawable(R.styleable.PictureProgressBar_drawable);
halfDrawableWidth = typedArray.getDimensionPixelSize(R.styleable.PictureProgressBar_halfDrawableWidth, 35);
halfDrawableHeight = typedArray.getDimensionPixelSize(R.styleable.PictureProgressBar_halfDrawableHeight, 35);
drawableHeightOffset = typedArray.getDimensionPixelSize(R.styleable.PictureProgressBar_drawableHeightOffset, 0);
isRound = typedArray.getBoolean(R.styleable.PictureProgressBar_isRound, true);
roundX = typedArray.getDimensionPixelSize(R.styleable.PictureProgressBar_roundX, 20);
roundY = typedArray.getDimensionPixelSize(R.styleable.PictureProgressBar_roundY, 20);
progress = typedArray.getInt(R.styleable.PictureProgressBar_progress, 0);
max = typedArray.getInt(R.styleable.PictureProgressBar_max, 100);
isSetBar = typedArray.getBoolean(R.styleable.PictureProgressBar_isSetBar, false);
progressHeight = typedArray.getDimensionPixelSize(R.styleable.PictureProgressBar_progressHeight, 30);
progressHeightOffset = typedArray.getDimensionPixelSize(R.styleable.PictureProgressBar_progressHeightOffset, 0);
refreshTime = typedArray.getInt(R.styleable.PictureProgressBar_refreshTime, 100);
animMode = typedArray.getInt(R.styleable.PictureProgressBar_animMode, ANIM_NULL);
rotateRate = typedArray.getInt(R.styleable.PictureProgressBar_rotateRate, 10);
rotateDegree = typedArray.getInt(R.styleable.PictureProgressBar_rotateDegree, 0);
scaleMax = typedArray.getFloat(R.styleable.PictureProgressBar_scaleMax, 2);
scaleMin = typedArray.getFloat(R.styleable.PictureProgressBar_scaleMin, 1);
scaleRate = typedArray.getFloat(R.styleable.PictureProgressBar_scaleRate, 0.1f);
gradientStartColor = typedArray.getColor(R.styleable.PictureProgressBar_gradientStartColor, Color.RED);
gradientEndColor = typedArray.getColor(R.styleable.PictureProgressBar_gradientEndColor, Color.YELLOW);
isGradient = typedArray.getBoolean(R.styleable.PictureProgressBar_isGradient, false);
backgroundDrawableId = typedArray.getResourceId(R.styleable.PictureProgressBar_backgroundDrawable,0);
barDrawableId = typedArray.getResourceId(R.styleable.PictureProgressBar_barDrawable,0);
typedArray.recycle();
init();
}
示例14: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs) {
TypedArray typedArray = context
.obtainStyledAttributes(attrs, R.styleable.WUBALoadingView);
mLoadText = typedArray.getString(R.styleable.WUBALoadingView_loadingText);
mTextAppearance = typedArray.getResourceId(R.styleable.WUBALoadingView_loadingTextAppearance, -1);
typedArray.recycle();
}
示例15: initAttrs
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void initAttrs(Context context, AttributeSet attrs, int defStyleAttr) {
mIndicatorHeight = (int) TypedValue
.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, mMetrics);
mUnderlineHeight = (int) TypedValue
.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, mMetrics);
mDividerWidth = (int) TypedValue
.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, mMetrics);
mDividerPaddingTop = (int) TypedValue
.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, mMetrics);
mDividerPaddingBottom = (int) TypedValue
.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, mMetrics);
mTabPaddingLeft = (int) TypedValue
.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, mMetrics);
mTabPaddingRight = (int) TypedValue
.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, mMetrics);
mTabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 12, mMetrics);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.HorizontalTabBar,
defStyleAttr, 0);
mIndicatorColor = a.getColor(R.styleable.HorizontalTabBar_horizontaltabbar_indicatorColor,
DEFAULT_INDICATOR_COLOR);
mUnderlineColor = a.getColor(R.styleable.HorizontalTabBar_horizontaltabbar_underlineColor,
DEFAULT_UNDERLINE_COLOR);
mDividerColor = a.getColor(R.styleable.HorizontalTabBar_horizontaltabbar_dividerColor,
DEFAULT_DIVIDER_COLOR);
mIndicatorHeight = a.getDimensionPixelSize(
R.styleable.HorizontalTabBar_horizontaltabbar_indicatorHeight, mIndicatorHeight);
mUnderlineHeight = a.getDimensionPixelSize(
R.styleable.HorizontalTabBar_horizontaltabbar_underlineHeight, mUnderlineHeight);
mDividerPaddingTop = a.getDimensionPixelSize(
R.styleable.HorizontalTabBar_horizontaltabbar_dividerPaddingTop,
mDividerPaddingTop);
mDividerPaddingBottom = a.
getDimensionPixelSize(
R.styleable.HorizontalTabBar_horizontaltabbar_dividerPaddingBottom,
mDividerPaddingBottom);
mTabPaddingLeft = a.getDimensionPixelSize(
R.styleable.HorizontalTabBar_horizontaltabbar_tabPaddingLeft, mTabPaddingLeft);
mTabPaddingRight = a.getDimensionPixelSize(
R.styleable.HorizontalTabBar_horizontaltabbar_tabPaddingRight, mTabPaddingRight);
mTabColor = a.getResourceId(R.styleable.HorizontalTabBar_horizontaltabbar_tabColor,
DEFAULT_TAB_COLOR);
mTabTextColor = a.getColor(R.styleable.HorizontalTabBar_horizontaltabbar_tabTextColor,
DEFAULT_TAB_TEXT_COLOR);
mSelectedTabTextColor = a.getColor(
R.styleable.HorizontalTabBar_horizontaltabbar_tabSelectedTextColor,
DEFAULT_SELECTED_TAB_TEXT_COLOR);
mTabTextSize = a.getDimension(
R.styleable.HorizontalTabBar_horizontaltabbar_tabTextSize, mTabTextSize);
mAverage = a.getBoolean(R.styleable.HorizontalTabBar_horizontaltabbar_isAverage, mAverage);
mTextAllCaps = a.getBoolean(R.styleable.HorizontalTabBar_horizontaltabbar_textAllCaps,
mTextAllCaps);
a.recycle();
}