相关疑难解决方法(0)

在Android 6.0 Marshmallow(API 23)上弃用了getColor(int id)

该Resources.getColor(int id)方法已被弃用.

@ColorInt
@Deprecated
public int getColor(@ColorRes int id) throws NotFoundException {
    return getColor(id, null);
}
Run Code Online (Sandbox Code Playgroud)

我该怎么办?

android android-resources android-mnc android-6.0-marshmallow

686
推荐指数
12
解决办法
27万
查看次数

不推荐使用getResources().getColor()

使用: buildToolsVersion "22.0.1", targetSdkVersion 22在我的gradle文件中.

我发现有用的getResources().getColor(R.color.color_name)是不推荐使用的.

我应该用什么呢?

android deprecated android-resources android-color

349
推荐指数
4
解决办法
17万
查看次数