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?
Asked
Active
Viewed 69 times
1 Answers
1
Try This:
ImageButton ib = new ImageButton(this);
yourContainer.addView(ib);//here yourContainer is ParentLayout

Subramanian Ramsundaram
- 1,362
- 1
- 9
- 10
-
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