Sunday, October 25, 2015

How to place hyperlink to a website on android app

Use This code in Activity class in Oncreate.

// 1) How to replace link by text like "Click Here to visit Google" and
    // the text is linked with the website url ?
    TextView link = (TextView) findViewById(R.id.textView1);
    String linkText = "Visit the <a href='http://stackoverflow.com'>StackOverflow</a> web page.";
    link.setText(Html.fromHtml(linkText));
    link.setMovementMethod(LinkMovementMethod.getInstance());

No comments:

Post a Comment