How to disable clicking on ListView in android? How to disable clicking on ListView in android? android android

How to disable clicking on ListView in android?


In your custom ArrayAdapter use isEnabled function to return false:

@Overridepublic boolean isEnabled(int position) {    return false;}

always works for me.


all the easier! list.setEnabled(false)


You can set the empty View as showed and it will be handled automatically:

 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"         android:orientation="vertical"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:paddingLeft="8dp"         android:paddingRight="8dp">     <ListView android:id="@android:id/list"               android:layout_width="match_parent"               android:layout_height="match_parent"               android:background="#00FF00"               android:layout_weight="1"               android:drawSelectorOnTop="false"/>     <TextView android:id="@android:id/empty"               android:layout_width="match_parent"               android:layout_height="match_parent"               android:background="#FF0000"               android:text="No data"/> </LinearLayout>