当前位置: 首页>>代码示例>>Java>>正文


Java ContextCompat.getColorStateList方法代码示例

本文整理汇总了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);
}
 
开发者ID:wutongke,项目名称:AndroidSkinAnimator,代码行数:13,代码来源:SkinCompatResources.java

示例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)));
}
 
开发者ID:MatthewTamlin,项目名称:Spyglass,代码行数:14,代码来源:TestColorStateListHandlerCombinations.java

示例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)));
}
 
开发者ID:MatthewTamlin,项目名称:Spyglass,代码行数:14,代码来源:TestColorStateListHandlerCombinations.java

示例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)));
}
 
开发者ID:MatthewTamlin,项目名称:Spyglass,代码行数:12,代码来源:TestColorStateListHandlerCombinations.java

示例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);
}
 
开发者ID:ximsfei,项目名称:Android-skin-support,代码行数:10,代码来源:SkinCompatResources.java

示例6: getColorStateList

import android.support.v4.content.ContextCompat; //导入方法依赖的package包/类
public ColorStateList getColorStateList(@ColorRes int id) {
    return ContextCompat.getColorStateList(mContext, id);
}
 
开发者ID:ttpho,项目名称:TimePicker,代码行数:4,代码来源:ResourceLoader.java

示例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();
}
 
开发者ID:michaelmuenzer,项目名称:ScrollableNumberPicker,代码行数:69,代码来源:ScrollableNumberPicker.java

示例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);
}
 
开发者ID:coopese,项目名称:qmui,代码行数:6,代码来源:QMUIResHelper.java

示例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);
}
 
开发者ID:coopese,项目名称:qmui,代码行数:6,代码来源:QMUILinkTextView.java

示例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);
}
 
开发者ID:axlecho,项目名称:tuxguitar,代码行数:6,代码来源:DrawableTools.java

示例11: getColorStateList

import android.support.v4.content.ContextCompat; //导入方法依赖的package包/类
public static ColorStateList getColorStateList(int resId){
    return ContextCompat.getColorStateList(Utils.getContext(),resId);
}
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:4,代码来源:ResouceUtil.java

示例12: getColorList

import android.support.v4.content.ContextCompat; //导入方法依赖的package包/类
public ColorStateList getColorList(@ColorRes int id) {
    return ContextCompat.getColorStateList(mActivity, id);
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:4,代码来源:UIIViewImpl.java

示例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);
}
 
开发者ID:youth5201314,项目名称:XFrame,代码行数:10,代码来源:XOutdatedUtils.java


注:本文中的android.support.v4.content.ContextCompat.getColorStateList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。