I want to place a hyperlink on android app that I am developing.
I tried this:
main.xml
Use the default Linkify class.
Here is an Example and the code from the tutorial:
This is my sample code for you, I think this will solve your problem:
public class StackOverflowActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// 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());
// 2) How to place email address
TextView email = (TextView) findViewById(R.id.textView2);
String emailText = "Send email: <a href=\"mailto:person@stackoverflow.com\">Click Me!</a>";
email.setText(Html.fromHtml(emailText));
email.setMovementMethod(LinkMovementMethod.getInstance());
}
}