getColor(int)已过时如何使用getColor(int,主题主题)
问题描述:
getColor(int)
已弃用。getColor(int)已过时如何使用getColor(int,主题主题)
如何使用getColor(int, theme theme)
?
我用了一些教训,我找不到我如何使用getColor(int, theme theme)
。
答
使用的东西作为
ResourcesCompat.getColor(getResources(), R.color.red, null)
(以API级别23的主题之前,将不会应用,因此它可能是null
。)
+0
我会建议使用'context.getTheme()'而不是'null'或者你可能只是使用不推荐的方法。 –
你看着资源? https://developer.android.com/reference/android/content/res/Resources.html#getColor(int,android.content.res.Resources.Theme) –