2

I have a custom listview which contains among other things a textview with a website in it. I have autoLink in the XML set to true so the link works fine and when tapped the browser opens however tapping the list item doesn't open the activity it is meant to open.

Is there a way to get this to function correctly?

sam
  • 2,469
  • 8
  • 37
  • 57

2 Answers2

3

Short Answer

I have experienced this problem before as well. The way I fixed this problem was by setting the text view's focusable property to false.

Longer answer

Basically the problem is that once a link is present, android resets the movement method on the TextView. This causes the focusabile property to be changed, and you can't have the text view be focusable if you want to be able to click on the list view item. Note, I had to call setFocusable programmatically instead of in the XML, but I was doing custom linking. Not sure if you are doing the same.

Justin Breitfeller
  • 13,737
  • 4
  • 39
  • 47
2

Try using

android:focusable="false"
android:focusableInTouchMode="false"

As attributes of your TextView. Although i haven't figure out why the selection background does not appear with linkify it does make that trick of calling the browser when link is tapped.

Necronet
  • 6,704
  • 9
  • 49
  • 89
  • This worked but the on click animation for the ListView items was lost. Do you know how to get that animation back? – Kevin Richards Jul 15 '15 at 09:15
  • I have posted the question here: http://stackoverflow.com/questions/31426409/textview-with-autolink-web-inside-listview-has-animation-issue – Kevin Richards Jul 15 '15 at 10:08