I have created an android application. In about box, I've given my web page address. Now this text is appearing as static text. My question is, is it possible to make this text clickable. That is, if I click this like, then the web page should open in default browser.
Asked
Active
Viewed 223 times
1
-
Do you want the hyperlink in alert box or in a segment on the screen? – Kunal S. Kushwah Jun 05 '13 at 04:45
-
1Here-- http://stackoverflow.com/questions/1997328/android-clickable-hyperlinks-in-alertdialog Check thi! It is the exact thing you want! :) – Kunal S. Kushwah Jun 05 '13 at 04:50
3 Answers
2
You can use this code. It may help you..
final AlertDialog dialog = new AlertDialog.Builder(ActivityName.this)
.setPositiveButton("OK", null)
.setIcon(R.drawable.icon)
.setMessage(Html.fromHtml("<a href=\"http://www.google.com\">Check this link out</a>"))
.create();
dialog.show();
// Make the textview clickable. Must be called after show()
((TextView)d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());

SAURABH_12
- 2,262
- 1
- 19
- 19
1
Did you try this?
((TextView)findViewById(R.id.txtMessage)).setText(Html.fromHtml("your html"));
((TextView)findViewById(R.id.txtMessage)).setMovementMethod(LinkMovementMethod.getInstance());

Vazedias
- 145
- 1
- 2
- 9
1
Use the below lines.
final AlertDialog.Builder alert = new AlertDialog.Builder(this);
final TextView input = new TextView(this);
alert.setView(input);
input.setText(Html.
fromHtml("www.google.com"));
Linkify.addLinks(input, Linkify.ALL);
alert.setMessage("Test");
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.cancel();
}
});
alert.show();
Hope this helps you.

itsrajesh4uguys
- 4,610
- 3
- 20
- 31