How set ListView not clickable

Tizianoreica picture Tizianoreica · Jul 30, 2013 · Viewed 43.6k times · Source

I have this ListView that just needs to show data.
So I don't want to make it clickable.
First I've tried changing XML listview to:

<ListView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:clickable="false" >

But it didn't work.
So to solve my problem I set through code:

  list.setSelector(android.R.color.transparent); 

but I can't believe there's no better solution. Any idea?

Answer

g00dy picture g00dy · Aug 7, 2013

Here it is, following the comment:

One way to do so is: ListView.setOnClickListener(null); OR

You can add android:focusable="false" android:focusableInTouchMode="false" OR

another way in the layout android:listSelector="@android:color/transparent"

Cheers.