I used a loop to create some dynamically generated buttons and in the same loop, I defined OnClickListener.
The summarized code:
for (int j = 0; j < list.size(); j++) {
Button button = new Button(this);
button.setId(j);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(view v) {
//Code
}
});
}
If any of them are clicked, then onClick is activated and all of them run the same code.
I wanna know how to get the id of clicked buttons.