I’m trying to just draw a simple image from the drawable-mdpi folder in android but I keep getting an error saying droid_1 cannot be resolved or is not a field, droid_1 is the name of the image, this is my code,
thanks for any help.
import android.R;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.view.View;
public class GameView extends View {
private Bitmap bmp;
public GameView(Context context) {
super(context);
bmp = BitmapFactory.decodeResource(getResources(), R.drawable.droid_1);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.BLACK);
canvas.drawBitmap(bmp, 10, 10, null);
}
}
Change “import android.R;” to “import “import com.your.package.R;” where com.your.package is your package name…