• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Create UI Items Dynamically and Call them

There are threads similar but not quite what I am looking for.
I want to be able to create buttons dynamically during run time when the user clicks the "New" button inside the menu.
I then need a way to dynamically name these buttons so i can call them for individual actions.
Any code or tips would be helpful. I know in c++ i would just create an integer counter and use that to name new items using string conversion but i dont think i can do that here.
 
There are threads similar but not quite what I am looking for.
I want to be able to create buttons dynamically during run time when the user clicks the "New" button inside the menu.
I then need a way to dynamically name these buttons so i can call them for individual actions.
Any code or tips would be helpful. I know in c++ i would just create an integer counter and use that to name new items using string conversion but i dont think i can do that here.

You do this just like you would in normal java. Create an instance of the Button class and then set its properties via the particualr methods and then add it to a layout.
 
Back
Top Bottom