当前位置:网站首页>'getColor(int)' is deprecated ,getColor过时
'getColor(int)' is deprecated ,getColor过时
2022-06-10 11:35:00 【yechaoa】
'getColor(int)' 在API 23(6.0)已经过时了
6.0之后使用:
ContextCompat.getColor(context, R.color.color_name)例如:
textView.setTextColor(ContextCompat.getColor(this, R.color.colorPrimary));源码:
@ColorInt
public static final int getColor(Context context, @ColorRes int id) {
final int version = Build.VERSION.SDK_INT;
if (version >= 23) {
return ContextCompatApi23.getColor(context, id);
} else {
return context.getResources().getColor(id);
}
}可以看出替代方法是兼容高版本和低版本的。
边栏推荐
猜你喜欢

Practice of Flink CDC + Hudi massive data entering the lake in SF

多线程杀手锏---countDownLatch&&CyclicBarrier

Cvpr22 oral | Hong Kong Chinese proposed transrank: sequencing loss + self supervision =sota

入门篇:从 etcd 名字的由来,到安装部署和使用姿势

In commemoration of the 16th day of the first month, the total number of visits to the studio exceeded one million

The facial scriptures of China Saibao

Weekly 5.28

好玩的人脸识别小软件

zoom如何在加入会议时关闭microphone

从 0 开始构建研发高效能全栈式团队
随机推荐
redis 面经详解
Dynamic programming (MID)
现场勘察制度
How zoom closes the microphone when joining a meeting
CVPR22 Oral | 港中文提出TransRank: 排序损失+自监督=SOTA
In commemoration of the 16th day of the first month, the total number of visits to the studio exceeded one million
After an error occurs in the source observable, it will be directly entered into the catchrror operator instead of the sequence in the pipe before entering the catchrror
并发bug之源(一)-可见性
Sword finger position operation
软件测试基础
Dell G7 computer shutdown keypad
Transfomer自实现与官方库
Flutter websocket example
纪念正月十六工作室总访问量突破百万
Fundamentals of software testing
SaaS management system for digital commerce cloud business service industry: to achieve efficient business collaboration and help enterprises improve their digital transformation
十三、系统调用和Shell(freestanding shell, 终端和 job control)
线性代数的本质5 行列式
如何配置多数据源
OAuth2学习中的一些高频问题的QA