How to make links in a TextView clickable?

后端 未结 30 3346

I have the following TextView defined:



        
30条回答
  •  青春惊慌失措
    2020-11-21 23:49

    Richard, next time, you should add this code under TextView at the layout XML instead.

    android:autoLink="all"
    

    This should be like this.

    
    
    

    You don't need to use this code (t2.setMovementMethod(LinkMovementMethod.getInstance());) in order to make the link clickable.

    Also, here's the truth: as long as you set the autoLink and the linksClickable, don't forget to add this at String.xml file so that the clickable link will work.

    Google
    

提交回复
热议问题