如何使用fromHTML打开URL?

问题描述 投票:0回答:1

我想用urlal打开Html.fromHtml(),标签之间的特定文字应该是绿色而不是下划线。

我现在怎么能这样做我这样做:

consent = consent.replace("<clickable>", "<a href=\"https://www.google.com/\"").replace("</clickable>", "</a>");
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
    consentCheck.setText(Html.fromHtml(consent, Html.FROM_HTML_MODE_LEGACY));
} else {
    consentCheck.setText(Html.fromHtml(consent));
}
java android html webview fromhtml
1个回答
0
投票

你有没有尝试过 :

textView.setMovementMethod(LinkMovementMethod.getInstance());

要改变颜色:

String blue = "this is blue";
SpannableString blueSpannable = new SpannableString(blue);
blueSpannable.setSpan(new ForegroundColorSpan(Color.BLUE), 0, blue.length(), 0);
builder.append(blueSpannable);

mTextView.setText(builder, BufferType.SPANNABLE);
© www.soinside.com 2019 - 2024. All rights reserved.