Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ListView with TextView autoLink not receiving OnItemClickListener

My PostFragment.java implements AbsListView.OnItemClickListener, and I get the onItemClick event without a problem on every item, unless there's a link on the TextView: lblListItem. The link on the TextView can be clicked without a problem and open a website, but the background of the list cannot be clicked and so the onItemClick is never called.

Example of a link string: http://www.google.com

I have this TextView on my list_item.xml:

        <TextView
        android:id="@+id/lblListItem"
        style="@style/TextView.ListItem"
        android:text="Text."
        android:layout_below="@+id/imgUser"
        android:layout_marginBottom="@dimen/margin_small"
        android:autoLink="all"
        android:linksClickable="true"
        />

I think that this is relevant, on my adapter I have some items that receive:

view.setOnClickListener()...

How can I make the list item clickable at the same time the link for the website is clickable?

like image 287
Rodrigo Direito Avatar asked Nov 17 '14 19:11

Rodrigo Direito


1 Answers

Try adding android:descendantFocusability="blocksDescendants" to the root view in your row layout. I've done some testing with this and it seems to work.

like image 84
JstnPwll Avatar answered Nov 15 '22 06:11

JstnPwll