1

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.

Gokul Nath KP
  • 15,485
  • 24
  • 88
  • 126

3 Answers3

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