how to dynamically create buttons?

by mnavlani » Fri, 02 Apr 2010 14:13:33 GMT


Sponsored Links
 hello all,
i wanted to create buttons at runtime. The no. of buttons to be
displayed depends upon the input of user. But creating a button
requires some code to be written in the .xml file. so how can i
dynamically generate the code for n no. of buttons at runtime?

regards!

--



how to dynamically create buttons?

by paresh mayani » Fri, 02 Apr 2010 15:06:20 GMT


 i think this will help you........
        Button b = new Button(this);
                        b.setText("Dynamic Button");
                        b.setLayoutParams(new 
LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));




--


Sponsored Links


how to dynamically create buttons?

by mnavlani » Fri, 02 Apr 2010 15:28:36 GMT


 thanks paresh!
i think this might help..
hey,
actually,the server would return an image at runtime. Now i want to
use this image for the dynamically created imagebutton...how can this
be done??

regards!

--



how to dynamically create buttons?

by ~ TreKing » Fri, 02 Apr 2010 21:04:01 GMT


 



If you take 2 seconds to read the documentation on ImageButton you will find
that it's quite simple to set which image it uses.

-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices
 http://sites.google.com/site/rezmobileapps/treking 

--