當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。