您的位置:首页 > 移动开发 > Android开发

android-6.0-23的getColor过时

2015-09-18 14:24 561 查看
getColor方法在6.0中已经过时:

@ColorInt
@Deprecated
public int getColor(@ColorRes int id) throws NotFoundException {
return getColor(id, null);
}


可以参考以下方法:

使用

ContextCompat.getColor(context, R.color.my_color)

This is the source code://源码
public static final int getColor(Context context, int id) {
final int version = Build.VERSION.SDK_INT;
if (version >= 23) {
return ContextCompatApi23.getColor(context, id);
} else {
return context.getResources().getColor(id);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: