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