- 首页 > it技术 > >
Android将文本中的URL转换为超链接工具类(原文本有超链接标签也适用)
public class TextToLinkUtil {public static String textContainUrlToLink(String urlText) {// 先拆分原字符串的超链接和文本
Spanned spanned = Html.fromHtml(urlText);
SpannableStringBuilder builder = new SpannableStringBuilder(spanned);
URLSpan[] spans = builder.getSpans(0, builder.length(), URLSpan.class);
String newUrlText = builder.toString();
ArrayList
推荐阅读