Switch Statement with Button pressed
So I push either button1, button2, button3, or button4. Pushing any of
these Buttons calls method buttonPressed(View v). I want to use a
different case depending on the button pressed. For example:
public void buttonPressed(View v){
switch(v){
case button1:
//do something
case button2:
//do something
case button3:
//do something
case button4:
//do something
}}
Obviously, this does not work. I cannot use a switch statement with a
View. What is the easiest and most efficient solution to this problem?
Thanks!!
Note: I am using android:onClick="buttonPressed" in my .xml
No comments:
Post a Comment