0

i want to insert an image to do a button. But i want insert it through the code, no with the .xml file. There is someone that have any idea?

Samjack
  • 190
  • 1
  • 1
  • 11

1 Answers1

1

Try This:

ImageButton ib = new ImageButton(this);
yourContainer.addView(ib);//here yourContainer is ParentLayout
  • Your "container" will be a layout,for example LinearLayout, which in turn inherits this method from ViewGroup. Look for the documentation here: http://developer.android.com/reference/android/view/ViewGroup.html#addView%28android.view.View%29 – bgse Nov 28 '13 at 19:27
  • how can i add an image to the image button? – Nitesh Verma Apr 06 '14 at 10:01