Java 我的类代码中不推荐的API在哪里?我搞不懂
这是一个简单的代码,错误消息没有说明不推荐使用的确切位置 正如代码所说,我将返回可绘制或颜色。很简单。需要更改的警告在哪里?如何跳过此警告,继续返回可绘制和颜色?在Android API 22中,getResources.getDrawable已被弃用。现在您应该使用这个方法getDrawable int-id,Resources.Theme API 23中不推荐使用getColor int id。现在改用getColorint,android.content.res.Resources.Theme 有关更多信息,请查看此链接: Android API 22中的getResources.getDrawable已被弃用。现在您应该使用这个方法getDrawable int-id,Resources.Theme API 23中不推荐使用getColor int id。现在改用getColorint,android.content.res.Resources.Theme 有关更多信息,请查看此链接:Java 我的类代码中不推荐的API在哪里?我搞不懂,java,android-studio,colors,drawable,deprecated,Java,Android Studio,Colors,Drawable,Deprecated,这是一个简单的代码,错误消息没有说明不推荐使用的确切位置 正如代码所说,我将返回可绘制或颜色。很简单。需要更改的警告在哪里?如何跳过此警告,继续返回可绘制和颜色?在Android API 22中,getResources.getDrawable已被弃用。现在您应该使用这个方法getDrawable int-id,Resources.Theme API 23中不推荐使用getColor int id。现在改用getColorint,android.content.res.Resources.The
我不知道。。。现在我使用的是ContextCompat.getColorcontext,R.color.color。还不确定如何在Resources.theme中使用主题。如何从Kotlin调用android.content.res.Resources.theme?不知道。。。现在我使用的是ContextCompat.getColorcontext,R.color.color。还不确定如何在Resources.theme中使用主题。如何从Kotlin调用android.content.res.Resources.theme?
package com.dev.marcellocamara.pgm.Helper;
import android.content.Context;
import android.graphics.drawable.Drawable;
import com.dev.marcellocamara.pgm.R;
public class CardHelper {
public static Drawable getBackground(Context context, int drawable){
switch (drawable){
case 1 : {
return (context.getResources().getDrawable(R.drawable.card_yellow));
}
case 2 : {
return (context.getResources().getDrawable(R.drawable.card_purple));
}
case 3 : {
return (context.getResources().getDrawable(R.drawable.card_green));
}
default : {
return null;
}
}
}
public static Drawable getFlag(Context context, int flag) {
switch (flag){
case 1 : {
return (context.getResources().getDrawable(R.drawable.flag1));
}
case 2 : {
return (context.getResources().getDrawable(R.drawable.flag2));
}
case 3 : {
return (context.getResources().getDrawable(R.drawable.flag3));
}
default : {
return null;
}
}
}
public static int getColor(Context context, int card) {
switch (card){
case 1 : {
return (context.getResources().getColor(R.color.card1));
}
case 2 : {
return (context.getResources().getColor(R.color.card2));
}
case 3 : {
return (context.getResources().getColor(R.color.card3));
}
default : {
return 0;
}
}
}
}