I want to open url
using Html.fromHtml()
also the particular text between tags should be green in color and not underline.
How can I do that right now I'm doing like this:
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));
}
Have you tried :
textView.setMovementMethod(LinkMovementMethod.getInstance());
To change color :
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);
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.