Clicking on overlapping user interface elements

I have Fragmentone that takes half Activity. Behind him a ListView. The problem is that when the user clicks on Fragment, which overlays the line in ListView, the button is pressed and the method is called onClick.

The workaround was onClick LinearLayoutin the layout XML file Fragment, for example:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.example.karimnseir.instabeat.IBMenuFragment"
    android:background="@color/material_blue_grey_950"
    android:onClick="doNothing">

Which I don’t think is very elegant, because I need to add a method doNothingfor everyone Activitythat uses thisFragment

If there is no way to stop onClicks from calling BEHIND elements Fragment, how can I still give it null onClickwithout using a dummy method everywhere?

thank

+4
source
1

android:onClick android:clickable="true". View .

+5

All Articles