我已经检查了很多关于stackoverflow的问题,我似乎拥有所有正确的东西,但我的R.drawable不会检测到我的图像.它位于/ res / drawable和所有其他文件夹中(mdpi,hdpi等)
ShipImage = context.getResources().getDrawable(R.drawable.player);
这是我的R.java
public static final class drawable { public static final int background=0x7f020000; public static final int buttons=0x7f020001; public static final int dead=0x7f020002; public static final int enemy=0x7f020003; public static final int ic_launcher=0x7f020004; public static final int play_btn=0x7f020005; public static final int player=0x7f020006; }
解决方法
您确定导入导入com.yourcompanyname.product.R吗?
代替
import android.R;