本文整理汇总了Java中android.support.v4.content.ContextCompat.getColorStateList方法的典型用法代码示例。如果您正苦于以下问题:Java ContextCompat.getColorStateList方法的具体用法?Java ContextCompat.getColorStateList怎么用?Java ContextCompat.getColorStateList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.content.ContextCompat
的用法示例。
在下文中一共展示了ContextCompat.getColorStateList方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getColorStateList
import android.support.v4.content.ContextCompat; //导入方法依赖的package包/类
public ColorStateList getColorStateList(int resId) {
ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId);
if (isDefaultSkin) {
return colorStateList;
}
String resName = mAppContext.getResources().getResourceEntryName(resId);
int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName);
return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId);
}
示例2: testSpyglassPassesCorrectData_attributePresent
import android.support.v4.content.ContextCompat; //导入方法依赖的package包/类
@Test
@UiThreadTest
public void testSpyglassPassesCorrectData_attributePresent() {
final AttributeSet attrs = fromXml(context, R.xml.color_state_list_handler_with_attr_equals_main_csl);
final ColorStateListHandlerTestTargetBase target = new WithoutDefault(context, attrs);
final ColorStateList expectedValue = ContextCompat.getColorStateList(
context,
R.color.main_color_state_list_for_testing);
assertThat(target.getReceivedValue(), is(ReceivedValue.of(expectedValue)));
}
示例3: testSpyglassPassesCorrectData_attributeMissing_defaultToColorStateListPresent
import android.support.v4.content.ContextCompat; //导入方法依赖的package包/类
@Test
@UiThreadTest
public void testSpyglassPassesCorrectData_attributeMissing_defaultToColorStateListPresent() {
final AttributeSet attrs = fromXml(context, R.xml.color_state_list_handler_without_attr);
final ColorStateListHandlerTestTargetBase target = new WithDefaultToColorStateListResource(context, attrs);
final ColorStateList expectedValue = ContextCompat.getColorStateList(
context,
R.color.default_color_state_list_for_testing);
assertThat(target.getReceivedValue(), is(ReceivedValue.of(expectedValue)));
}
示例4: testSpyglassPassesDataCorrectly_noAttributesSupplied_defaultToColorStateListPresent
import android.support.v4.content.ContextCompat; //导入方法依赖的package包/类
@Test
@UiThreadTest
public void testSpyglassPassesDataCorrectly_noAttributesSupplied_defaultToColorStateListPresent() {
final ColorStateListHandlerTestTargetBase target = new WithDefaultToColorStateListResource(context);
final ColorStateList expectedValue = ContextCompat.getColorStateList(
context,
R.color.default_color_state_list_for_testing);
assertThat(target.getReceivedValue(), is(ReceivedValue.of(expectedValue)));
}
示例5: getColorStateList
import android.support.v4.content.ContextCompat; //导入方法依赖的package包/类
public ColorStateList getColorStateList(int resId) {
ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId);
if (isDefaultSkin) {
return colorStateList;
}
int targetResId = getTargetResId(resId);
return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId);
}
示例6: getColorStateList
import android.support.v4.content.ContextCompat; //导入方法依赖的package包/类
public ColorStateList getColorStateList(@ColorRes int id) {
return ContextCompat.getColorStateList(mContext, id);
}
示例7: init
import android.support.v4.content.ContextCompat; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs) {
if (isInEditMode()) {
return;
}
LayoutInflater layoutInflater =
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layoutInflater.inflate(R.layout.number_picker, this);
TypedArray typedArray =
context.obtainStyledAttributes(attrs, R.styleable.ScrollableNumberPicker);
Resources res = getResources();
downIcon = typedArray.getResourceId(R.styleable.ScrollableNumberPicker_snp_buttonIconDown, downIcon);
upIcon = typedArray.getResourceId(R.styleable.ScrollableNumberPicker_snp_buttonIconUp, upIcon);
leftIcon = typedArray.getResourceId(R.styleable.ScrollableNumberPicker_snp_buttonIconLeft, leftIcon);
rightIcon = typedArray.getResourceId(R.styleable.ScrollableNumberPicker_snp_buttonIconRight, rightIcon);
mMinValue = typedArray.getInt(R.styleable.ScrollableNumberPicker_snp_minValue,
res.getInteger(R.integer.default_minValue));
mMaxValue = typedArray.getInt(R.styleable.ScrollableNumberPicker_snp_maxValue,
res.getInteger(R.integer.default_maxValue));
mStepSize = typedArray.getInt(R.styleable.ScrollableNumberPicker_snp_stepSize,
res.getInteger(R.integer.default_stepSize));
mUpdateIntervalMillis = typedArray.getInt(R.styleable.ScrollableNumberPicker_snp_updateInterval,
res.getInteger(R.integer.default_updateInterval));
mOrientation = typedArray.getInt(R.styleable.ScrollableNumberPicker_snp_orientation,
LinearLayout.HORIZONTAL);
mValue = typedArray.getInt(R.styleable.ScrollableNumberPicker_snp_value,
res.getInteger(R.integer.default_value));
mValueTextSize = typedArray.getDimension(R.styleable.ScrollableNumberPicker_snp_value_text_size,
INVALID_RES);
mValueTextColor = typedArray.getColor(R.styleable.ScrollableNumberPicker_snp_value_text_color,
0);
mValueTextAppearanceResId = typedArray.getResourceId(R.styleable.ScrollableNumberPicker_snp_value_text_appearance, INVALID_RES);
mScrollEnabled = typedArray.getBoolean(R.styleable.ScrollableNumberPicker_snp_scrollEnabled,
res.getBoolean(R.bool.default_scrollEnabled));
mButtonColorStateList = ContextCompat.getColorStateList(context, typedArray.getResourceId(R.styleable.ScrollableNumberPicker_snp_buttonBackgroundTintSelector, R.color.btn_tint_selector));
mValueMarginStart = (int) typedArray.getDimension(R.styleable.ScrollableNumberPicker_snp_valueMarginStart, res.getDimension(R.dimen.default_value_margin_start));
mValueMarginEnd = (int) typedArray.getDimension(R.styleable.ScrollableNumberPicker_snp_valueMarginStart, res.getDimension(R.dimen.default_value_margin_end));
mButtonPaddingLeft = (int) typedArray.getDimension(R.styleable.ScrollableNumberPicker_snp_buttonPaddingLeft, res.getDimension(R.dimen.default_button_padding_left));
mButtonPaddingRight = (int) typedArray.getDimension(R.styleable.ScrollableNumberPicker_snp_buttonPaddingRight, res.getDimension(R.dimen.default_button_padding_right));
mButtonPaddingTop = (int) typedArray.getDimension(R.styleable.ScrollableNumberPicker_snp_buttonPaddingTop, res.getDimension(R.dimen.default_button_padding_top));
mButtonPaddingBottom = (int) typedArray.getDimension(R.styleable.ScrollableNumberPicker_snp_buttonPaddingBottom, res.getDimension(R.dimen.default_button_padding_bottom));
TypedValue outValue = new TypedValue();
res.getValue(R.dimen.default_button_scale_factor, outValue, true);
float defaultValue = outValue.getFloat();
mButtonTouchScaleFactor = typedArray.getFloat(R.styleable.ScrollableNumberPicker_snp_buttonTouchScaleFactor, defaultValue);
typedArray.recycle();
initViews();
mAutoIncrement = false;
mAutoDecrement = false;
mUpdateIntervalHandler = new Handler();
}
示例8: getAttrColorStateList
import android.support.v4.content.ContextCompat; //导入方法依赖的package包/类
public static ColorStateList getAttrColorStateList(Context context, int attrRes){
TypedValue typedValue = new TypedValue();
context.getTheme().resolveAttribute(attrRes, typedValue, true);
return ContextCompat.getColorStateList(context, typedValue.resourceId);
}
示例9: QMUILinkTextView
import android.support.v4.content.ContextCompat; //导入方法依赖的package包/类
public QMUILinkTextView(Context context) {
this(context, null);
mLinkBgColor = null;
mLinkTextColor = ContextCompat.getColorStateList(context, R.color.qmui_s_link_color);
}
示例10: getTinyDrawable
import android.support.v4.content.ContextCompat; //导入方法依赖的package包/类
public static Drawable getTinyDrawable(Context context, @DrawableRes int drawableRes, int colorStateListRes) {
Drawable drawable = getDrawable(context,drawableRes);
ColorStateList colorStateList = ContextCompat.getColorStateList(context,colorStateListRes);
return getTinyDrawable(drawable, colorStateList);
}
示例11: getColorStateList
import android.support.v4.content.ContextCompat; //导入方法依赖的package包/类
public static ColorStateList getColorStateList(int resId){
return ContextCompat.getColorStateList(Utils.getContext(),resId);
}
示例12: getColorList
import android.support.v4.content.ContextCompat; //导入方法依赖的package包/类
public ColorStateList getColorList(@ColorRes int id) {
return ContextCompat.getColorStateList(mActivity, id);
}
示例13: getColorStateList
import android.support.v4.content.ContextCompat; //导入方法依赖的package包/类
/**
* getColorStateList过时方法处理
*
* @param id 资源id
* @return
*/
public static ColorStateList getColorStateList(@ColorRes int id) {
return ContextCompat.getColorStateList(XFrame.getContext(), id);
}