Tuesday, 15 July 2014

android - I need to get the id of the dynamically generating button -


With this code it creates dynamic buttons for the value given from the second layout. I need to get his ID and add another button (if I click the dynamic button then I need to add another button dynamically).

 for  (int i = 0; i  

If I correctly understood additional information provided on your comment , You need it to know when a user clicks on a button you can set an OnClickListener on your button.

  // somewhere in your activity. . Override public null on @reate (bundle saved instainstate) {super.naught (savedinstenstate); SetContentView (R.layout.main); Button Button = (Button) Find VVBIID (R.B. button 1); Button.setOnClickListener (New OnClickListener) {Public void onClick (see v) {// button is clicked! Whatever you want.}}); } // ... // The rest of the code // ...  

Of course, you should replace R.id.button1 with your button's ID.


No comments:

Post a Comment