How to switch button image from on to off and vice versa upon click?
I have been trying to switch the state of my buttons from on to off and vice versa, by adding an image for on and adding an image for off state. I tried through xml, however I was just able to temporarily switch it upon click (by using press/focus etc). Here is the code for the same: fragment_justin: <RelativeLayout android:id="@+id/top_bar_container" android:layout_width="match_parent" android:layout_height="48.5dp" android:layout_alignParentTop="true" android:background="@color/background_action_bar" android:orientation="horizontal" > <ImageButton android:id="@+id/menu_button" android:layout