Ashok
Ashok

Reputation: 227

How to change backgroundcolor of clicked row in a single choice listview

I want to create a single choice listview in which when an item is pressed i should be able to change the background color of the item pressed. I have tried setting the backgroundcolor of the view parameter passed to the onItemClick function but this changes the backgrouncolor of someother item. After the background color change i want to make the Listview non clickable. I have tried setting clickable and focusable to false in the onItemClick handler function but that doesnt help. I also want to be able to populate this ListView with new data and then make it clickable again later. I will have only four listviewitems so is it better not to use the listview at all and may be use four buttons.

Thanks

Upvotes: 1

Views: 1600

Answers (1)

Konstantin Burov
Konstantin Burov

Reputation: 69238

You need to use a stateful drawable. See the question for more details.

Upvotes: 1

Related Questions