Error:(15, 23) error: cannot find symbol method setTint(Drawable,int)

Error:(15, 23) error: cannot find symbol method setTint(Drawable,int)

我正在将 eclipse 项目导入 android studio,在 eclipse 中它工作正常但在 android studio 中它有 setTint 问题。

这是我的 drawablecompat 设置:

public static void tintWidget(Context ctx, View view, int color) {
    Drawable wrappedDrawable = view.getBackground();
    DrawableCompat.setTint(wrappedDrawable, ctx.getResources().getColor(color));
    view.setBackgroundDrawable(wrappedDrawable);
}

with DrawableCompat.setTintList 也不起作用,setTintList

出错

正确的代码是什么?

您似乎缺少对 app compat v4 的依赖项,请尝试将其添加到您的 build.gradle:

dependencies {
    compile 'com.android.support:support-v4:22.2.0'
}

或者您需要的任何 SDK 版本而不是 22.2.0

看看:https://developer.android.com/tools/studio/eclipse-transition-guide.html#dependencies