简体   繁体   中英

How do I prevent a ListView from receiving clicks when another View or Fragment is over it?

I have a ListView that displays some data. The rows can be clicked as well. I also have a custom Fragment at the bottom of the screen that "hovers" over the ListView all the time. I want this Fragment to also pick up click events so that I can do stuff when it's clicked.

The issue is that I can't figure out how to do that, and the ListView ends up getting the click instead, even when the Fragment covers that particular row.

Basically, I want to make sure that when there is a Fragment (or even another View) on top of the ListView, that Fragment registers the click when I click on it, and not the ListView. How do I do this?

If another View or Fragment is over it, you can prevent clicks from reaching through by setting the android:clickable attribute to true on the root of the layout that is presented on top of something else clickable.

The same goes for the layout inflated in the Fragment displayed on top of something else, just set android:clickable to true on the root of the inflated layout.

android:clicable="true"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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