Using HTML in Android Alert Dialog

As it turns out, you don't actually need any extra TextViews to do this. Simply include the HTML in your alert's "setMessage()" call (which replaces the "setView()" call in your question) and pass it the html-formatted string. Be sure to only use <b>, <u>, and <i> in your formatting, though because those are the only tags it supports. If you're using a String resource for the text in your alert, call getResources().getText(R.id.yourHtmlString) rather than getResources().getString(R.id.yourHtmlString), though, or the tags will be completely stripped from the String.


You will need to use Html.fromHtml() to use HTML tags in TextView as:

msg.setText(Html.fromHtml("<u>Message</u>"))

And you also see all HTML tags supported by TextView.