美文网首页
TextView 设置超链接无效的解决方法

TextView 设置超链接无效的解决方法

作者: 阳光下的美好_6e13 | 来源:发表于2018-09-06 09:56 被阅读133次

    1.代码设置

     tv.setText(Html.fromHtml("<a href='https://www.taobao.com/'>满1件100元5折</a>"));
    //激活超链接,设置为可点击模式
     tv.setMovementMethod(LinkMovementMethod.getInstance());
    

    2.xml

    注意:android:autoLink这行代码一定不要设置,否则会无效

      <TextView
            android:id="@+id/tv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hello World!"  />
        <!--android:autoLink="web"-->
    

    相关文章

      网友评论

          本文标题:TextView 设置超链接无效的解决方法

          本文链接:https://www.haomeiwen.com/subject/mcmtgftx.html