Hi I have something like this (3 buttons) in my activity xml pointing to same method:
<Button
android:id="@+id/Button_1"
android:onClick="printNo"
android:text="@string/Button_1" />
<Button
android:id="@+id/Button_2"
android:onClick="printNo"
android:text="@string/Button_2" />
<Button
android:id="@+id/Button_3"
android:onClick="printNo"
android:text="@string/Button_3" />
Is there any way I could determine which button was pressed while in the printNo method ?
public void printNo( View v ) {
switch (v.getId()) {
case (R.id.Button_1):
//stuff
break;
case (R.id.Button_2):
//stuff
break;
case (R.id.Button_3):
//stuff
break;
}