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 

--



Other Threads

1. question about KeyListener

I need to listen to user's input of a edittext. I first use
KeyListener to listen.it can work,but it also eating other input.So I
changed to the OnKeyListener, and it work well
   then I read Api about  KeyListener, I find the sentence below I
can't understand
   Calling this method will replace the current content type of the
text view with the content type returned by the key listener.
    I guess it's the reason why it's eating other input.but I can't
make sure. because I can't understand the sentence,Can any one explain
it to me?
--~--~---------~--~----~------------~-------~--~----~

2. api's to display an image file stored in local folder

Hi all,

        i want to write an application which can display an image
(jpeg,png...) . as a begginer i dont know which are the api's that can
be used .could you give me your valuable suggestions .

--~--~---------~--~----~------------~-------~--~----~

3. Limit the size of a ScrollView

4. No ticks when using AlertDialog.setMultiChoiceItems with cursor

5. Remounting SDCARD in the emulator

6. Tracking Pointer Events in Android Browser

7. how to stop service?