i’m trying to create a Bitmap
BitmapDrawable img = new BitmapDrawable(getResources(), "res/drawable/wrench.png");
Bitmap wrench = img.getBitmap();
//Bitmap wrench = BitmapFactory.decodeResource(getResources(), R.drawable.wrench);
canvas.drawColor(Color .BLACK);
Log.d("OLOLOLO",Integer.toString(wrench.getHeight()));
canvas.drawBitmap(wrench, left, top, null);
but when i call wrench.getHeight() program failed with NullPoinerException. (i put the file in drawable directory)
how can i solve my problem?
Ok… I think I have a handle on your problem now. Like I said, you can’t access your drawables via a path, so if you want a human readable interface with your drawables that you can build programatically, declare a HashMap somewhere in your class:
Then initialize it in your constructor:
Now for access –