0

I wanted to Display Calendar Icon as a Button In Android. I have created a Image Button as,

ImageButton DtPk = new ImageButton(this);  

I know that image will set as,

Drawable d = Drawable.createFromPath("@drawable/calendar");
DtPk.setBackgroundDrawable(d);

But where do i store image in my project? And how.

NullUserException
  • 83,810
  • 28
  • 209
  • 234
posteritysystem
  • 973
  • 2
  • 7
  • 20

1 Answers1

0

When the project was created you should see a folder called "res" and inside it several different drawable folders. Place the image inside of the one called drawable-mdpi. Then simple do the following:

DtPk.setImageResource(R.drawable.calendar);

Here is another SO post explaining more about drawable folders: Drawable folders in res folder?

And read the section called Bitmap File in this document: http://developer.android.com/guide/topics/resources/drawable-resource.html

Community
  • 1
  • 1
Salil Pandit
  • 1,498
  • 10
  • 13