I have been searching for a solution to this issue which seems rather trivial. I have an ExpandableListView with various child elements, including a TextView. I would like links to be detected in the TextView, so I have tried using android:autoLink="web"
and also Linkify.addLinks(textView, Linkify.WEB_URLS);
Either will create hyperlinks in the TextView. The problem that I have encountered is that when there is a link in the TextView, the ExpandableListView item with a link will no longer expand when touching any elements within the item.
I have added android:descendantFocusability="blocksDescendants"
to top most layout of ExpandableListView item. This allows the item to expand, but only when touching any other child element within the item. If I touch non-hyperlinked text within TextView with link, onGroupExpand is never called. If I set android:linksClickable="false"
, it expands as it should, the links are highlighted, but obviously the links are then not clickable and do nothing.
I have read this answer here, ExpandableListView centains a link does not expand, which states it is not possible, however that does not appear to be true, as android:descendantFocusability="blocksDescendants"
allows it, just not when touching non-hyperlinked text. I've read this is a bug here, https://code.google.com/p/android/issues/detail?id=3414, but it was declined.
How can I make the links clickable while also making item expand when touching any of the non-hyperlinked TextView text?
来源:https://stackoverflow.com/questions/16824187/android-expandablelistview-with-clickable-links-in-child-textview-wont-expand-w