ListView with TextView autoLink does not get OnItemClickListener

My PostFragment.java implements AbsListView.OnItemClickListener , and I get onItemClick with no problem on every element if there is no link to TextView: lblListItem . The link to the TextView can be clicked without problems and open the website, but the background of the list cannot be clicked, and therefore onItemClick is never called.

Example link bar: 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 this is relevant, on my adapter I have some elements that get:

 view.setOnClickListener()... 

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

+5
source share
1 answer

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

+8
source

Source: https://habr.com/ru/post/1207065/


All Articles