Skip to main content
added 42 characters in body
Source Link
CopsOnRoad
  • 271.2k
  • 97
  • 702
  • 471

I didn't really like the currently most popular answer because it significantly changes the formatting of the message in the dialog.

Here's a solution that will linkify your dialog text without otherwise changing the text styling:

 // Linkify the message final SpannableString s = new SpannableString(msg); // msg should have url to enable clicking Linkify.addLinks(s, Linkify.ALL); final AlertDialog d = new AlertDialog.Builder(activity) .setPositiveButton(android.R.string.ok, null) .setIcon(R.drawable.icon) .setMessage( s ) .create(); d.show(); // Make the textview clickable. Must be called after show() ((TextView)d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); 

I didn't really like the currently most popular answer because it significantly changes the formatting of the message in the dialog.

Here's a solution that will linkify your dialog text without otherwise changing the text styling:

 // Linkify the message final SpannableString s = new SpannableString(msg); Linkify.addLinks(s, Linkify.ALL); final AlertDialog d = new AlertDialog.Builder(activity) .setPositiveButton(android.R.string.ok, null) .setIcon(R.drawable.icon) .setMessage( s ) .create(); d.show(); // Make the textview clickable. Must be called after show() ((TextView)d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); 

I didn't really like the currently most popular answer because it significantly changes the formatting of the message in the dialog.

Here's a solution that will linkify your dialog text without otherwise changing the text styling:

 // Linkify the message final SpannableString s = new SpannableString(msg); // msg should have url to enable clicking Linkify.addLinks(s, Linkify.ALL); final AlertDialog d = new AlertDialog.Builder(activity) .setPositiveButton(android.R.string.ok, null) .setIcon(R.drawable.icon) .setMessage( s ) .create(); d.show(); // Make the textview clickable. Must be called after show() ((TextView)d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); 
Source Link
emmby
  • 100.6k
  • 67
  • 197
  • 252

I didn't really like the currently most popular answer because it significantly changes the formatting of the message in the dialog.

Here's a solution that will linkify your dialog text without otherwise changing the text styling:

 // Linkify the message final SpannableString s = new SpannableString(msg); Linkify.addLinks(s, Linkify.ALL); final AlertDialog d = new AlertDialog.Builder(activity) .setPositiveButton(android.R.string.ok, null) .setIcon(R.drawable.icon) .setMessage( s ) .create(); d.show(); // Make the textview clickable. Must be called after show() ((TextView)d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());