Reputation: 2757
I'm completely new to Android and I'm developing a widget that has multiple buttons. The action that must be taken for each of these buttons is logically the same. The only thing I would need is to know which button was clicked. Do I have to use different Action
s and set them to an Intent
for every Button or is there a more efficient way? I tried to create custom buttons with custom XML attributes but that seemed too complicated and flexible for this purpose.
Any help would be greatly appreciated.
Upvotes: 0
Views: 365
Reputation: 2586
You can use the Button's onClick attribute to specify a method in the host activity that will be called when the button is called This method will pass in a View object as a parameter which is the button that was clicked, based on which you can change your logic as required.
Upvotes: 1