I have an android program where I have multiple buttons using the same OnClickListener, and I want to be able to reference the button’s dynamically assigned text from inside the listener. Is there some way to reference the button that was pushed to get its text? I don’t want to have to make multiple button-specific listeners that do the same thing.
I have an android program where I have multiple buttons using the same OnClickListener,
Share
In your onClick(View v) you can cast it to a button: