Hey guys.I’m new to android and with the help of stackoverflow I somehow managed to switch between images by checking for state using an xml and changing the image. Now I have another togglebutton in the same activity,so is there any way to use the same xml to do the switching or do I have to create a new one ? Because the images are different.
This is the xml code I used from this site .
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true"
android:drawable="@drawable/pause" /> <!-- pressed -->
<item android:drawable="@drawable/play" /> <!-- default/unchecked -->
</selector>
Kindly help.
You have to create another selector with the drawables for the second togglebutton, since here’s no info except drawable per state, so you have nothing common in 2 togglebuttons’ selectors.