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


Java ResourcesCompat.getColor方法代码示例

本文整理汇总了Java中android.support.v4.content.res.ResourcesCompat.getColor方法的典型用法代码示例。如果您正苦于以下问题:Java ResourcesCompat.getColor方法的具体用法?Java ResourcesCompat.getColor怎么用?Java ResourcesCompat.getColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.content.res.ResourcesCompat的用法示例。


在下文中一共展示了ResourcesCompat.getColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: update

import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
public void update() {
    mTemperatureTextView.setText(String.format("%d", mDevice.getTemperature()));

    int activeColor = ResourcesCompat.getColor(getResources(), R.color.colorPrimary, null);
    int inactiveColor = ResourcesCompat.getColor(getResources(), R.color.colorSecondaryText, null);

    final Device.Mode mode = mDevice.getMode();

    setImageButtonColorFilter(R.id.autoModeButton, mode == Device.Mode.AUTO ? activeColor : inactiveColor);
    setImageButtonColorFilter(R.id.coolModeButton, mode == Device.Mode.COOL ? activeColor : inactiveColor);
    setImageButtonColorFilter(R.id.dryModeButton, mode == Device.Mode.DRY ? activeColor : inactiveColor);
    setImageButtonColorFilter(R.id.fanModeButton, mode == Device.Mode.FAN ? activeColor : inactiveColor);
    setImageButtonColorFilter(R.id.heatModeButton, mode == Device.Mode.HEAT ? activeColor : inactiveColor);
    setImageButtonColorFilter(R.id.powerButton, mDevice.isPoweredOn() ? activeColor : inactiveColor);

    setSwitchChecked(R.id.airSwitch, mDevice.isAirModeEnabled());
    setSwitchChecked(R.id.healthSwitch, mDevice.isHealthModeEnabled());
    setSwitchChecked(R.id.xfanSwitch, mDevice.isXfanModeEnabled());
    setSwitchChecked(R.id.sleepSwitch, mDevice.isSleepModeEnabled());
    setSwitchChecked(R.id.quietSwitch, mDevice.isQuietModeEnabled());
    setSwitchChecked(R.id.turboSwitch, mDevice.isTurboModeEnabled());
    setSwitchChecked(R.id.energySavingSwitch, mDevice.isSavingModeEnabled());
    setSwitchChecked(R.id.lightSwitch, mDevice.isLightEnabled());

    ((SeekBar) findViewById(R.id.fanSpeedSeekBar)).setProgress(mDevice.getFanSpeed().ordinal());
}
 
开发者ID:tomikaa87,项目名称:gree-remote,代码行数:27,代码来源:DeviceActivity.java

示例2: onCreate

import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    //textshow = (TextView) findViewById(R.id.textView1);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final Resources resources = getResources();
    final Resources.Theme theme = getTheme();
    mColorHearing = ResourcesCompat.getColor(resources, R.color.status_hearing, theme);
    mColorNotHearing = ResourcesCompat.getColor(resources, R.color.status_not_hearing, theme);

    //setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    mStatus = (TextView) findViewById(R.id.status);
    mText = (TextView) findViewById(R.id.textView1);
    mRespond= (TextView) findViewById(R.id.textView3);

    mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    final ArrayList<String> results = savedInstanceState == null ? null :
            savedInstanceState.getStringArrayList(STATE_RESULTS);
    mAdapter = new ResultAdapter(results);
    mRecyclerView.setAdapter(mAdapter);

   /* outputFile = Environment.getExternalStorageDirectory().
            getAbsolutePath() + "/audio.raw";*/
}
 
开发者ID:hsavaliya,项目名称:GoogleAssistantSDK,代码行数:27,代码来源:MainActivity.java

示例3: ContactAdapter

import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
public ContactAdapter(Context context, List<Contact> contacts, ContactSelectionListener listener, String selectedIconHex, byte[] selectedDrawable) {
    super(contacts);
    this.mMaterialColors = context.getResources().getIntArray(R.array.colors);
    this.mContacts = contacts;
    this.mSelection = new ArrayList<>();
    this.selectedColor = ResourcesCompat.getColor(context.getResources(), R.color.color_7,null);
    this.subtitleColor= ResourcesCompat.getColor(context.getResources(), R.color.subtitle,null);
    this.mListener = listener;

    if(selectedIconHex == null)
        this.selectedIconColor = ResourcesCompat.getColor(context.getResources(),R.color.materialGreen, null);
    else
        this.selectedIconColor = Color.parseColor(selectedIconHex);

    if(selectedDrawable != null)
        this.selectedDrawable = PickerUtils.extractDrawable(selectedDrawable);
    else
        this.selectedDrawable = PickerUtils.extractDrawable(PickerUtils.sendDrawable(context.getResources(),R.drawable.ic_done));
}
 
开发者ID:quiin,项目名称:UnifiedContactPicker,代码行数:20,代码来源:ContactAdapter.java

示例4: getImportanceColor

import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
public int getImportanceColor() {
    switch (importance) {
        case 0: return ResourcesCompat.getColor(getResources(), R.color.colorTimeLeft0, null);
        case 1: return ResourcesCompat.getColor(getResources(), R.color.colorTimeLeft1, null);
        case 2: return ResourcesCompat.getColor(getResources(), R.color.colorTimeLeft2, null);
        case 3: return ResourcesCompat.getColor(getResources(), R.color.colorTimeLeft3, null);
        default: return ResourcesCompat.getColor(getResources(), R.color.colorTimeLeft4, null);
    }
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:10,代码来源:TimeLeftCalendarFragment.java

示例5: getColorByImportance

import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
final private int getColorByImportance(int importance) {
    switch (importance) {
        case 0: return ResourcesCompat.getColor(getResources(), R.color.colorHabit0, null);
        case 1: return ResourcesCompat.getColor(getResources(), R.color.colorHabit1, null);
        case 2: return ResourcesCompat.getColor(getResources(), R.color.colorHabit2, null);
        case 3: return ResourcesCompat.getColor(getResources(), R.color.colorHabit3, null);
        default: return ResourcesCompat.getColor(getResources(), R.color.colorHabit4, null);
    }
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:10,代码来源:HabitCalendarFragment.java

示例6: getColorByImportance

import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
final private int getColorByImportance(int importance) {
    switch (importance) {
        case 0: return ResourcesCompat.getColor(getResources(), R.color.colorTask0, null);
        case 1: return ResourcesCompat.getColor(getResources(), R.color.colorTask1, null);
        case 2: return ResourcesCompat.getColor(getResources(), R.color.colorTask2, null);
        case 3: return ResourcesCompat.getColor(getResources(), R.color.colorTask3, null);
        default: return ResourcesCompat.getColor(getResources(), R.color.colorTask4, null);
    }
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:10,代码来源:TaskCalendarFragment.java

示例7: getColor

import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
@ColorInt
private int getColor() {
    int i = ++sIndex;
    if (i >= COLOR.length) {
        i = sIndex = 0;
    }
    return ResourcesCompat.getColor(getResources(), COLOR[i], getActivity().getTheme());
}
 
开发者ID:aesean,项目名称:Rotate3d,代码行数:9,代码来源:SampleFragmentV4.java

示例8: getColors

import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
private static int[] getColors(@NonNull Context context, int[] colorResourceIds) {
    Resources resources = context.getResources();
    int[] colors = new int[colorResourceIds.length];
    for (int colorIndex = 0; colorIndex < colorResourceIds.length; colorIndex++) {
        colors[colorIndex] = ResourcesCompat.getColor(resources, colorResourceIds[colorIndex], null);
    }
    return colors;
}
 
开发者ID:neXenio,项目名称:BLE-Indoor-Positioning,代码行数:9,代码来源:ColorUtil.java

示例9: getColorFromScore

import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
public static int getColorFromScore(float score) {

		int color = ResourcesCompat.getColor(resources, R.color.mediumGray, null);
		if (score == 0) {
			color = ResourcesCompat.getColor(resources, R.color.mediumGray, null);
		} else if (score > 0 && score <= 2) {
			color = ResourcesCompat.getColor(resources, R.color.red, null);
		} else if (score > 2 && score < 3.5) {
			color = ResourcesCompat.getColor(resources, R.color.yellow, null);
		} else if (score >= 3.5) {
			color = ResourcesCompat.getColor(resources, R.color.green, null);
		}
		return color;
	}
 
开发者ID:EduardoVernier,项目名称:bikedeboa-android,代码行数:15,代码来源:AssetHelper.java

示例10: setPositiveBackgroundColorResource

import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
public Builder setPositiveBackgroundColorResource(@ColorRes int buttonColorRes) {
    this.btn_colorPositiveBackground = ResourcesCompat.getColor(context.getResources(), buttonColorRes, null);
    return this;
}
 
开发者ID:myinnos,项目名称:ImageSaveandShare,代码行数:5,代码来源:BottomDialog.java

示例11: setPositiveTextColorResource

import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
public Builder setPositiveTextColorResource(@ColorRes int textColorRes) {
    this.btn_colorPositive = ResourcesCompat.getColor(context.getResources(), textColorRes, null);
    return this;
}
 
开发者ID:myinnos,项目名称:ImageSaveandShare,代码行数:5,代码来源:BottomDialog.java

示例12: setNegativeTextColorResource

import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
public Builder setNegativeTextColorResource(@ColorRes int textColorRes) {
    this.btn_colorNegative = ResourcesCompat.getColor(context.getResources(), textColorRes, null);
    return this;
}
 
开发者ID:myinnos,项目名称:ImageSaveandShare,代码行数:5,代码来源:BottomDialog.java

示例13: setBackgroundResource

import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
public Builder setBackgroundResource(@ColorRes int backgroundResource) {
    this.params.backgroundColor = ResourcesCompat.getColor(this.params.context.getResources(), backgroundResource, null);
    return this;
}
 
开发者ID:Codigami,项目名称:CFAlertDialog,代码行数:5,代码来源:CFAlertDialog.java

示例14: setDialogBackgroundResource

import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
public Builder setDialogBackgroundResource(@ColorRes int backgroundResource) {
    this.params.dialogBackgroundColor = ResourcesCompat.getColor(this.params.context.getResources(), backgroundResource, null);
    return this;
}
 
开发者ID:Codigami,项目名称:CFAlertDialog,代码行数:5,代码来源:CFAlertDialog.java

示例15: setItemTextColorResource

import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
public BottomSheetBuilder setItemTextColorResource(@ColorRes int color) {
    mItemTextColor = ResourcesCompat.getColor(mContext.getResources(), color,
            mContext.getTheme());
    return this;
}
 
开发者ID:yuhodev,项目名称:login,代码行数:6,代码来源:BottomSheetBuilder.java


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