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("<a href='https://play.google.com/store/apps/details?id=com.xxxxxxxxx'>Click Here</a>")
Note the single quotes around the URL.
Solution 2:
AlertDialog.Builder builder1 = new AlertDialog.Builder(youractivity.this);
builder1.setMessage(Html.fromHtml("your message,<a href=\"http://www.google.com\">link</a>"));
builder1.setCancelable(false);
builder1.setPositiveButton("ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
AlertDialog Alert1 = 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>" +
"<a href='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?"