自定义 ListView 在单击时不突出显示 ListViewItem
我有一个由 ImageView 和 TextView 组成的自定义列表视图。单击效果很好,但它不会像普通 ListView 那样突出显示该项目。我该如何添加亮点?我尝试通过在单击时设置背景颜色然后添加计时器来删除背景颜色来对其进行装配。这有效,但我想要一个更好的解决方案。有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
单击ListView,然后在属性窗口中,将drawSelectorOnTop 设置为true。我刚刚遇到了同样的问题,这就像一个魅力。
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.
我认为您可以尝试使用 colorstate。定义 state_pressed、state_selected 和任何其他适当状态的颜色,然后将视图的背景设置为 colorstate。
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.