Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make button as hyperlink in android

Tags:

android

How can I create a button whose text look like a hyperlink text.

like image 868
Arun Badole Avatar asked May 24 '11 10:05

Arun Badole


3 Answers

Easy, you just have to create an TextView and enable the property autoLink="all", and you don't need to pass any HTML, only the url inside a text or just the url.

Example:

    <TextView
        android:id="@+id/tvLink"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center"
        android:text="Please click www.google.com.br and search for anything!"
        android:autoLink="all"/>
like image 187
fpauer Avatar answered Oct 16 '22 22:10

fpauer


in your string.xml add:

<string name="Test"><a href="http://www.bla.com">Test</a></string>

in your TextView add the attribute:

android:autoLink="all"
like image 28
ayahya82 Avatar answered Oct 16 '22 23:10

ayahya82


I did this way in my Project

Uri uri = Uri.parse("http://www.example.com"); 
Intent intent = new Intent(Intent.ACTION_VIEW, uri); 
startActivity(intent);
like image 31
Givantha Kalansuriya Avatar answered Oct 16 '22 22:10

Givantha Kalansuriya