Autolink inside a TextView in android

前端 未结 5 1975
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-14 02:57

How to give autolink for some part of textview ? For example : My text inside TextView is \"Please click here to open this webpage\". I want to show link for only the text \

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-14 03:23

    Put a String in string.xml

    
    
        Support: click here
    
    

    And you can use it in textView like this:

    
    

    EDIT

    For some reason above code does not work properly. So, add below code also,

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

提交回复
热议问题