Skip to content Skip to sidebar Skip to footer

How To Have Text And Clickable Url Link On Alertdialog?

I read sample codes and tried something below, but it doesn't work. The text didn't appear to be a hyperlink. Please help:( String randomString = XXXX.getString(); if(rando

Solution 1:

You're missing quotes around your URL. Try:

Html.fromHtml("<ahref='https://play.google.com/store/apps/details?id=com.xxxxxxxxx'>Click Here</a>")

Note the single quotes around the URL.

Solution 2:

AlertDialog.Builderbuilder1=newAlertDialog.Builder(youractivity.this);

builder1.setMessage(Html.fromHtml("your message,<a href=\"http://www.google.com\">link</a>"));

builder1.setCancelable(false);
builder1.setPositiveButton("ok", newDialogInterface.OnClickListener() {
    @OverridepublicvoidonClick(DialogInterface dialog, int which) {
    }
});

AlertDialogAlert1= builder1.create();
Alert1 .show();
((TextView)Alert1.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());

Solution 3:

You need to use all in HTML style

like this

Html.fromHtml(
"<b>Hello</b><br>" +
"<ahref='https://play.google.com/store/apps/details?id=com.xxxxxxxxx'>Click Here</a>"
)

Post a Comment for "How To Have Text And Clickable Url Link On Alertdialog?"