1、getDrawable
之前代码中获取Drawable都是使用如下方法:
Drawable drawable = getResources().getDrawable(int id);
但是此方法过时,不推荐使用
当前替代的使用方法
谷歌推荐使用 // 同时兼容高、低版本
Drawable drawable = ContextCompat.getDrawable(Context context,int id);
2、getColor
之前代码中获取Color都是使用如下方法:
getResources().getColor(int id);
但是此方法过时,不推荐使用
当前替代的使用方法
谷歌推荐使用 // 同时兼容高、低版本
ContextCompat.getColor(Context context, int id);