Custom ListView not highlighting ListViewItem on click

女生的网名这么多〃 提交于 2019-12-07 00:11:21

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/4621675/custom-listview-not-highlighting-listviewitem-on-click

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!