T
T
thatmaniscool2021-12-06 15:18:25
Android
thatmaniscool, 2021-12-06 15:18:25

How to handle clicking on dynamically created buttons in android studio?

I create a dynamic array from CardView. CardView contains a button to open another activity.
I made a simple listener with a toast, when pressed, the button identifier is displayed.
The only problem is that the indicator is the same everywhere, and I need to open different activations.
How to properly handle the button click in this case?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
thatmaniscool, 2021-12-06
@thatmaniscool

If anyone needs it, you need to set the button.setId indicator.
After that, in the handler, you need to call the indicator and compare it with the necessary one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question