Android – TextView autoLink attribute

By -

Today this tutorial is about the autoLink attribute of TextView.

andorid:autoLink => By using this attribute, android can controls whether links(such as urls, emails, phone and address) are automatically found and converted to clickable links. In other meaning we can say whenever we display any kind of number then it assume we have entered phone numbers inside the text view so it directly links to the dial screen whenever text view is clicked , same way for email (redirected to any email app like yahoo or gmail) , map(directly plotted the address on a google map if address found), urls(opens urls in a browser).

Here it is given on Android site: Android autoLink

Now let me explore all the values one by one.

1. android:autoLink=”email”

<TextView
	android:id="@+id/txtViewEmail"
	android:layout_width="fill_parent"
	android:layout_height="wrap_content"
	android:text="Email id: abc@gmail.com"
	android:autoLink="email"
	android:textSize="16sp"
	android:layout_margin="5dip">
</TextView>

2. android:autoLink=”phone”

<TextView
	android:id="@+id/txtViewPhone"
	android:layout_width="fill_parent"
	android:layout_height="wrap_content"
	android:text="Phone no: 12345"
	android:autoLink="phone"
	android:textSize="16sp"
	android:layout_margin="5dip">
</TextView>

3. android:autoLink=”web”

<TextView
	android:id="@+id/txtViewWeb"
	android:layout_width="fill_parent"
	android:layout_height="wrap_content"
	android:text="Web: www.pareshnmayani.wordpress.com"
	android:autoLink="web"
	android:textSize="16sp"
	android:layout_margin="5dip">
</TextView>

4. android:autoLink=”map”

<TextView
	android:id="@+id/txtViewAddress"
	android:layout_width="fill_parent"
	android:layout_height="wrap_content"
	android:text="Address: 381 Park Avenue South, New York"
	android:autoLink="map"
	android:textSize="16sp"
	android:layout_margin="5dip">
</TextView>

Issue: While testing with “map” value, i am facing one issue while setting any location of India, it is not being converted to clickable links. If you are knowing and having suggestion regarding the same then please feel free to share with me and here.

CEO & Co-Founder at SolGuruz® | Organiser @ GDG Ahmedabad | Top 0.1% over StackOverflow | 15+ years experienced Tech Consultant | Helping startups with Custom Software Development

Loading Facebook Comments ...
Loading Disqus Comments ...