【发布时间】:2023-03-17 07:24:01
【问题描述】:
现在不推荐使用新的 android API 22 getResources().getDrawable()。
现在最好的方法是只使用getDrawable()。
发生了什么变化?
【问题讨论】:
-
您能具体说明您的问题吗?不推荐使用
Resources类的方法getDrawable (int id)是对的。您现在应该使用方法getDrawable (int id, Resources.Theme theme)和新的主题参数。 -
ContextCompat.getDrawable(context, R.color.color_name)
-
您可以查看有关此主题的 my blog post,以更全面地了解为什么不推荐使用
Resources#getDrawable(int)和Resources#getColor(int)。 -
Google 应该为每个已弃用的功能提供快速修复。我在这里发了一个帖子:code.google.com/p/android/issues/detail?id=219495
标签: android android-drawable android-resources android-5.1.1-lollipop