You can invoke the static addLinks()
method of the Linkify class
to find and add links to the content of any TextView
or any Spannable on demand.
Linkify.addLinks(tv, Linkify.ALL);
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> /*from w w w .jav a2 s . c om*/ <TextView android:id="@+id/myText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="abc@yourserver.com" android:autoLink="email" /> </LinearLayout>
Java code
package com.java2s.app; // ww w .j a va2s .c om import android.app.Activity; import android.os.Bundle; import android.text.util.Linkify; import android.widget.TextView; public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TextView nameValue = (TextView)findViewById(R.id.myText); Linkify.addLinks(nameValue, Linkify.ALL); } }