简体   繁体   English

禁用Listview上的涟漪效应

[英]Disable ripple effect on Listview

I have a simple listview that has some listitems. 我有一个简单的listview,有一些listitems。 Currently, to make the items ripple on touch, I just added android:drawSelectorOnTop="true" to the listview. 目前,为了使项目在触摸时波动,我只是将android:drawSelectorOnTop="true"到listview。

This works perfectly. 这非常有效。

However, some of the list items are headers and should not show ripples because they do not have an action associated with them. 但是,某些列表项是标题,不应显示涟漪,因为它们没有与之关联的操作。 How can I disable the ripple effect for only the headers? 如何仅为标题禁用涟漪效应?

The listview contains linearlayouts for the rows and the headers. 列表视图包含行和标题的线性布局。

I tried the following on the header with no success: 我在标题上尝试了以下操作但没有成功:

  • setting clickable to false 设置clickable为false
  • setting listSelector to null. listSelector设置为null。
  • setting focusable to false. focusable设置为false。

Can anyone point me in the right direction? 谁能指出我正确的方向?

Possibly a duplicate question . 可能是一个重复的问题 But as a summary: try disabling those elements in your adapter. 但作为总结:尝试禁用适配器中的这些元素。 You can use the .areAllItemsEnabled() and .isEnabled() callbacks for this purpose. 为此,您可以使用.areAllItemsEnabled().isEnabled()回调。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM