gpt4 book ai didi

java - getResources().getColor() 即使在 API 检查后也显示已弃用

转载 作者:行者123 更新时间:2023-11-30 09:59:21 24 4
gpt4 key购买 nike

<分区>

我做了 API 检查,但它在编译时显示弃用警告。

private void tab_sel(boolean whi_one){
View vie1 = findViewById(R.id.tab_sel1);
View vie2 = findViewById(R.id.tab_sel2);
int whi, gra, pos, neg;

if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {
whi = getResources().getColor(R.color.white);
gra = getResources().getColor(R.color.tabInactive);
} else {
whi = getColor(R.color.white);
gra = getColor(R.color.tabInactive);
}

if(whi_one){
vie1.setVisibility(View.VISIBLE);
vie2.setVisibility(View.INVISIBLE);
pos = whi;
neg = gra;
} else {
vie1.setVisibility(View.INVISIBLE);
vie2.setVisibility(View.VISIBLE);
pos = gra;
neg = whi;
}

tv_pos_tit.setTextColor(pos);
tv_pos_bal.setTextColor(pos);
tv_neg_tit.setTextColor(neg);
tv_neg_bal.setTextColor(neg);
}

当它显示弃用警告时,有人能告诉我吗?它显示

whi = getResources().getColor(R.color.white) and 
gra = getResources().getColor(R.color.tabInactive)

作为弃用行

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com