Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dear Chris,
- If I understand that Article (along with your kind assistance correctly):
- In my onCreateOptionsMenu() I used to have the line:
- switchCompat.setThumbResource(R.drawable.ic_toggle_sound); <-- where ( ic_toggle_sound ) is the microphone icon showing ON-State.
- First I would need to create an accompanying second graphic, lets call it ( ic_toggle_sound_off ) and place in the drawables.
- Then I create a brand new xml selector file (let's call it ic_speaker_selector.xml)... and use that to replace the line above like:
- switchCompat.setThumbResource(ic_speaker_selector); <-- I am assuming without the .xml extension.
- this ic_speaker_selector.xml would reside inside my ( res/drawable ) folder and since I only have two toggle sates:
- (ON - or checked) versus (OFF - or unchecked), then my code would probably look something like this (if I am not mistaken)
- ----------------------------- ic_speaker_selector.xml should look like this ------------------------------------------------
- <selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_checked="true" android:drawable="@drawable/ic_sound_on" />
- <item android:state_checked="false" android:drawable="@drawable/ic_sound_off" />
- </selector>
- -----------------------------------------------------------------------------------------------------------------------------------
- Do I have it right ?
- Thanks !
- Alexander
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement