I'm using a ListView with a custom Adapter and custom item layout where every item has a description with a switch.
Depending on what the item is, I give the switch different thumb selector-drawables per code in getView()
.
swtch.setThumbDrawable(getContext().getResources()
.getDrawable(R.drawable.green_switch)); // or red_switch
This works fine, but: When I scroll the ListView, the custom images are gone, until I touch a switch again, then the custom image of it comes back immediately.
When the state list contains an element of the “disabled” state at first, the switch will have this image instead of the image it should.
It's either a bug or an improperly use of the ListAdapter by me, I think.
A workaround for me would be to include switches with different styles in the layout and show one of them depending on the item type I have and hide the others.
Is this the only possibility?