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