1

Android - Button Listener Knows Which Button Was Clicked

view story
linux-howto

http://stackoverflow.com – I'm assigning a button listener to multiple buttons like so: for(Button b : buttons) { b.setOnClickListener(clicklisten); } The button listener is defined as follows: private OnClickListener clicklisten = new OnClickListener() { public void onClick(View v) { Context context = getApplicationContext(); text = Toast.makeText(context, " Button Clicked", Toast.LENGTH_SHORT); text.show(); } }; As it is, it just shows a Toast with "Button Clicked" displaying. I'd like it to detect which button is clicked, perhaps via the name or ID of that (HowTos)