I have created 3 buttons in my application which when clicked, will go to the method giveClue.
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="24dp"
android:layout_height="22dp"
android:layout_alignTop="@+id/lifeButtonsLbl"
android:layout_toLeftOf="@+id/ImageButton2"
android:src="@drawable/icon"
android:onClick="giveClue" />
<ImageButton
android:id="@+id/ImageButton2"
android:layout_width="24dp"
android:layout_height="22dp"
android:layout_alignTop="@+id/imageButton1"
android:layout_toLeftOf="@+id/ImageButton3"
android:src="@drawable/icon"
android:onClick="giveClue"/>
<ImageButton
android:id="@+id/ImageButton3"
android:layout_width="24dp"
android:layout_height="22dp"
android:layout_alignRight="@+id/frameLayout1"
android:layout_alignTop="@+id/ImageButton2"
android:src="@drawable/icon"
android:onClick="giveClue" />
NOTE: I don't want to use different method for the
ACTIVITY CLASS:
public void giveClue(View view) {
gameAdapter.giveClue(game);
}
My problem is that I want to disable the button that was clicked.I don't want to use different method for each button. Is it possible to determine which button was clicked so I can disable it.
Thank you.
Check for view.getId() in the giveClue method and compare it to R.id.imageButton1 etc. Normally done with a switch-case :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With