开发者

How to create Link button in android

I want to create Link button in android. Can anyone guide me in how I c开发者_StackOverflow中文版an create a Link button in android?


Simple. Just put the link in your TextView.

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

Note: The most important property here is android:autoLink="all". This allow you to link to urls, emails and phone numbers.

In your strings.xml add the link:

<string name="about_link"><a href='http://example.com'>http://example.com</a></string>
<string name="about_email"><a href='mailto:admin@example.com'>admin@example.com</a></string>

I know this answer is coming really late, but hope it helps someone else coming along.


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜