android getResources.getColor(R.color.colorId)方法遭弃用

我们在开发过程中,偶尔会遇到部分api会被划一下,也就是当前使用的API过时了,那么官方肯定给出的有其替代API。现在要说的就是在android 23(6.0)及以上getResources.getColor(R.color.colorId)API过时时,那么它的替代方法为

ContextCompat.getColor(context,R.color.colorId);可以使用最新的V4兼容包中的ContextCompat,这样也可以兼容低版本的平台。


转载连接:https://blog.csdn.net/lvshuchangyin/article/details/60579194

猜你喜欢

转载自blog.csdn.net/yijiaodingqiankun/article/details/80908195