本文整理匯總了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());
}
示例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";*/
}
示例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));
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}