iperetz1
iperetz1

Reputation: 1

Switch and case option

I have an activity with 5 buttons. I want to use the switch option. How can I detect which button is clicked?

Upvotes: 0

Views: 327

Answers (1)

softarn
softarn

Reputation: 5496

Here is a guide: http://developer.android.com/guide/topics/ui/ui-events.html

Inside onClick(View v):

switch(v.getId()){   
  case R.id.nameofbutton: 
    //do this 
    break;  
}

Upvotes: 2

Related Questions