【问题标题】:How to create Link button in android如何在android中创建链接按钮
【发布时间】:2011-11-25 05:27:00
【问题描述】:

我想在 android 中创建链接按钮。 谁能指导我如何在 android 中创建链接按钮?

【问题讨论】:

    标签: android-widget


    【解决方案1】:

    简单。只需将链接放在您的 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"。这允许您链接到 url、电子邮件和电话号码。

    在您的 strings.xml 中添加链接:

    <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>
    

    我知道这个答案来得太晚了,但希望它可以帮助其他人。

    【讨论】:

      【解决方案2】:
      Uri uri = Uri.parse("http://www.example.com"); 
      Intent intent = new Intent(Intent.ACTION_VIEW, uri); 
      startActivity(intent);
      

      【讨论】:

        猜你喜欢
        • 2011-08-15
        • 2022-01-25
        • 1970-01-01
        • 2015-06-18
        • 1970-01-01
        • 1970-01-01
        • 2016-07-10
        • 2011-11-04
        • 2018-06-14
        相关资源
        最近更新 更多