Custom ListView not highlighting ListViewItem on click
Asked Answered
I

2

7

I have a custom listview made up of an ImageView and a TextView. Clicking works fine however it won't highlight the item like a normal ListView would. How would I add a highlight? I tried to rig it by setting the background color on click and then adding a timer to remove the background color. That worked but I want a better solution. Any ideas?

Indefinable answered 7/1, 2011 at 1:14 Comment(1)
How did you create your custom ListView? You are probably doing something wrong if that is not working.Dinny
D
3

I think you can try to use the colorstate. Define the colors for state_pressed, state_selected and any other appropriate states, then set the background of your view to the colorstate.

Dave answered 7/1, 2011 at 1:28 Comment(1)
Hey be aware that setting the background should use DRAWABLE resource but not COLOR resource. look at thisCaraway
I
5

Click on your ListView and then in the properties window, set drawSelectorOnTop to true. I just had the same issue and that worked like a charm.

Implication answered 4/5, 2013 at 4:24 Comment(1)
Definitely the easiest answer. Works perfectly!Sphygmic
D
3

I think you can try to use the colorstate. Define the colors for state_pressed, state_selected and any other appropriate states, then set the background of your view to the colorstate.

Dave answered 7/1, 2011 at 1:28 Comment(1)
Hey be aware that setting the background should use DRAWABLE resource but not COLOR resource. look at thisCaraway

© 2022 - 2024 — McMap. All rights reserved.