有三个类(Resources / ContextCompat / AppCompatResources
)都有getDrawable
方法,但是什么情况下使用什么类的getDrawable
方法呢?
在使用Android getDrawable
方法过程中,总结!
Resources
调用

这个方法,添加了对Theme
这个参数。

这个方法在
API 22
已经弃用了。
ContextCompat
调用

AppCompatResources
调用

推荐使用
Drawable batWarmIndOn = AppCompatResources.getDrawable(mAct,R.drawable.ic_warning_battery_plug);
网友评论