String htmlText = Html.toHtml((Spanned) editText.getText());
//output of htmlText = "<span style="background-color:#F9F9F9;"><b><a href="someUrl">Some Text</a></b></span>"
How can I get the URL link in the <a>
tag so that I'll have something like
String urlStr = "someUrl";
Okay... I was able to figure it out with the help of the comment from @CommonsWare.
First, I had to add the JSoup
library to my android project then with this code below
String htmlText = Html.toHtml((Spanned) editText.getText());
Document doc = Jsoup.parse(htmlText, "UTF-8");
Elements element = doc.select("a");
String href = element.attr("href");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.