What I am trying to accomplish is to have clickable hyperlinks in the message text displayed by an AlertDialog
. While the AlertDialog
implementation happily underlines and colors any hyperlinks (defined using <a href="...">
in the string resource passed to Builder.setMessage
) supplied the links do not become clickable.
The code I am currently using looks like this:
new AlertDialog.Builder(MainActivity.this).setTitle(
R.string.Title_About).setMessage(
getResources().getText(R.string.about))
.setPositiveButton(android.R.string.ok, null)
.setIcon(R.drawable.icon).show();
I'd like to avoid using a WebView
to just display a text snippet.
Simplest way:
JFTR, here comes the solution which I figured out after some time:
The corresponding about.xml borrowed as a fragment from the Android sources looks like this:
The important parts are setting linksClickable to true and setMovementMethod(LinkMovementMethod.getInstance()).