ListView with TextView autoLink not receiving OnItemClickListener
Asked Answered
S

1

8

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?

Scar answered 17/11, 2014 at 19:17 Comment(0)
H
9

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.

Henshaw answered 17/11, 2014 at 20:4 Comment(1)
Simple as that, worked like a charm. Thank you kind sir!Scar

© 2022 - 2024 — McMap. All rights reserved.