How to make button as hyperlink in android
How can I create a button whose tex开发者_如何学JAVAt look like a hyperlink text.
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"/>
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"
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);
Create a String (named hyperlink) in string.xml and give its value like link and then set property android:setText="@string/hyperlink" to Button.
精彩评论