I have a problem. In my app I have an Activity where I need to create x Button, then add to all this Button an ActionListener that start another activity.
In details. I have a Database table where I store x name.
In my Activity I need to have a Button for each name stored in the db and to add to each button an actionListener so when you click it it start another activity (which is the same for all buttons) with a putExtra String (which is unique for each button).
I thought that I can get all the name via an AsyncTask. But I can't figure out how to add the Buttons to the basic layout and add the Action Listener to them.
Anyone can help?
P.S. The "putExtra" String is the name I got from the db. So I also thought to get them in String[] array. Then create a Button[] array (don't know if it's possible) and create a new Button() foreach element of the String[] array. Then foreach element in the Button[] array I would putExtra the relative index String. Like Button[0] have as a putExtra the String[0], Button[1] the String[1] and so on.