I try to make a TextView as hyperlink. This one worked as expected :
content.text = "<a href=${args.article.url}>Content</a>".fromHtml()
But I get a lint warning regarding using string resources. But this one does now show TextView as hyperlink:
content.text = getString(R.string.content, args.article.url).fromHtml()
And this is String resource :
<string name="content"><a href="%s">Content</a></string>
Is there any solution to fix it using String resource?
@Suppress("DEPRECATION")
fun String.fromHtml() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Html.fromHtml(this, Html.FROM_HTML_MODE_COMPACT)
} else {
Html.fromHtml(this)
}
getText()instead ofgetString()/fromHtml(): stackoverflow.com/a/19311520/115145getText(R.string.content, args.article.url).fromHtml()I receive an error underargs.article.urlgetText()doesn't support placeholders. You could switch to the single-parametergetText()and useTextUtils.expandTemplate()orTextUtils.replace().