0

I have a ListView(with HTML text) which contains hyperlinks in it. I am using the following code to open the hyperlinks in browser :

holder.txtTitle = (TextView)row.findViewById(R.id.answerText);
        holder.txtTitle.setMovementMethod(LinkMovementMethod.getInstance());
        holder.txtTitle.setAutoLinkMask(Linkify.WEB_URLS);

While this works fine, I notice that sometimes text like "R.abc" or "foo.bar" are also recognised as URLs and opened as hyperlinks on click. How do I differentiate between these and actual hyperlinks ?

Thanks !

Shivam Bhalla
  • 1,879
  • 5
  • 35
  • 63
  • The problem is, foo.bar could be a URL (think google.com). You need to be more specific about what you think a URL is supposed to look like. – Knossos Apr 28 '15 at 10:08
  • Yes, that way I think any two words separated by a '.' could be a URL. Isn't there any way to see if it is a 'valid' URL ? – Shivam Bhalla Apr 28 '15 at 10:09
  • That IS a valid URL. You could test whether it contains a http:// or similar. You could use regular expressions. However, here be dragons. – Knossos Apr 28 '15 at 10:15
  • I think you have to use regular expression for it to check whether your text contain any url and if yes then is valid or not according to that regular expression. – Bhagwat K Apr 28 '15 at 10:17
  • use webview in that case you dont have to write anything for redirect – amodkanthe Apr 28 '15 at 10:19

0 Answers0