如何在Android中使按钮成为超链接

问题描述

| 如何创建一个按钮,其文本看起来像超链接文本。     

解决方法

在string.xml中创建一个String(名为超链接),并提供其值(例如link),然后将android:setText = \“ @ string / hyperlink \”属性设置为Button。     ,容易,您只需要创建一个TextView并启用属性autoLink = \“ all \”,就不需要传递任何HTML,只需传递文本中的url或仅传递url。 例:
    <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\"/>
    ,在您的string.xml中添加:
<string name=\"Test\"><a href=\"http://www.bla.com\">Test</a></string>
在您的TextView中添加属性:
android:autoLink=\"all\"
    ,我在项目中这样做
Uri uri = Uri.parse(\"http://www.example.com\"); 
Intent intent = new Intent(Intent.ACTION_VIEW,uri); 
startActivity(intent);
    

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...