Code example for SpannableString

Methods: addLinks, setMessage

0
public class DialogUtils { 
    // See bug report: http://code.google.com/p/android/issues/detail?id=2219 
    // From workaround at http://stackoverflow.com/questions/1997328/android-clickable-hyperlinks-in-alertdialog 
    public static void showHTMLDialog(Context context, String html) {
        // Linkify the message 
        final SpannableString s = new SpannableString(Html.fromHtml(html));
        Linkify.addLinks(s, Linkify.ALL);
        final AlertDialog d = new AlertDialog.Builder(context)
                .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());
    } 
 
}