How to make markdown links and normal urls clickable in same textview.

I have a string, with two types of links inside it.

One is markdown and the other is normal link.

I want both of them to be clickable inside a textView.

This is the string :

String myString = "[google](www.google.com) www.facebook.com"

I converted myString to HTML using AndDown library.

AndDown andDown = new AndDown(); String convertedString = andDown.markdownToHtml( myString );

The value of convertedString now :

"google www.facebook.com"

Now if I set the textview as below :

textView.setLinksClickable(true); body.setMovementMethod(LinkMovementMethod.getInstance()); body.setText(convertedString);

This is how my textView looks like :

google www.facebook.com

google is now clickable, where as www.facebook.com is not recognized as a link, it's printed as a normal word.

To solve this I used :

textView.setAutoLinkMask(Linkify.ALL);

This made www.facebook.com clickable, but google is now not recognized as link, but is displayed as a normal word.

So, I need a solution to make them both clickable, without trading off either of them.

Category:android Time:2018-11-29 Views:3

Related post

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 0.976 (s). 13 q(s)