2011-09-26 76 views

回答

15

简单。只要把链接放在你的TextView中。

<TextView 
    android:id="@+id/txtLink" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/about_link" 
    android:autoLink="all" /> 

注意:这里最重要的属性是android:autoLink="all"。这使您可以链接到网址,电子邮件和电话号码。

在strings.xml添加链接:

<string name="about_link"><a href='http://example.com'>http://example.com</a></string> 
<string name="about_email"><a href='mailto:[email protected]'>[email protected]</a></string> 

我知道这个答案是真的来晚了,但希望它可以帮助别人磨磨蹭蹭。

3
Uri uri = Uri.parse("http://www.example.com"); 
Intent intent = new Intent(Intent.ACTION_VIEW, uri); 
startActivity(intent); 
+0

与所提问题甚至不尽相同 –