I want text view as a clickable link
All tested and working 100%
below is a complete example
Solution: android:autoLink="web"
Sample Xml:
<TextView android:id="@+id/txtLostpassword" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:autoLink="email" android:gravity="center" android:padding="20px" android:text="@string/lostpassword" android:textAppearance="?android:attr/textAppearanceSmall" /><TextView android:id="@+id/txtLostpassword" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:autoLink="web" android:gravity="center" android:padding="20px" android:text="@string/defaultpassword" android:textAppearance="?android:attr/textAppearanceSmall" />
String in string.xml
<string name="lostpassword">If you lost your password please contact <a href="mailto:support@cleverfinger.com.au?Subject=Lost%20Password" target="_top">support@cleverfinger.com.au</a></string><string name="defaultpassword">User Guide <a href="http://www.cleverfinger.com.au/user-guide/">http://www.cleverfinger.com.au/user-guide/</a></string>
You can add click listener to TextView and start websearch:
textView.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { Intent browser= new Intent(Intent.ACTION_VIEW, Uri.parse(PASTE_YOUR_URL_HERE)); startActivity(browser); }});
and xml looks like:
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/link_string" android:textSize="14dp" android:autoLink="web" />