How to make links in a TextView clickable?

后端 未结 30 3269

I have the following TextView defined:



        
30条回答
  •  既然无缘
    2020-11-21 23:39

    The following should work for anyone who is looking for a combination of text and hyperlink within an Android app.

    In string.xml:

    Looking for Digital Visiting card? 
    Get it here
    
    

    Now you can utilise this string in any given View like this:

    
    

    Now, in your Activity or Fragment, do the following:

    TextView getapp =(TextView) findViewById(R.id.getapp);
    getapp.setMovementMethod(LinkMovementMethod.getInstance());
    

    By now, you don't require to set android:autoLink="web" or android:linksClickable="true" using this approach.

    I hope you will find this helpful.

提交回复
热议问题