getDrawable - Set a Drawable Object Variable

Drawable was added in API Level 1

1. Create an Drawable Variable named myDrawable.

2. In the MainActivity.java file, add the following line. This will get an instance of a Drawable. This will set the myDrawable to the drawable named R.drawable.myImage.

try {
    myDrawable = getResources().getDrawable(R.drawable.myImage);
} catch { Resources.NotFoundException e)
    e.printStackTrace();
}


3. Compile and run!

Next Recommended Article: Set a Drawable to an ImageView

Resources:
developer.android.com/reference/android/content/Context.html#getResources()
http://developer.android.com/reference/android/content/res/Resources.html#getDrawable(int)