How to create TextView that will act as a link

后端 未结 4 745
长情又很酷
长情又很酷 2020-12-30 17:41

I have a Textview with location:

eg. \"Mountain View, CA\"

What I want to achieve is to create this text to act like a Link - color,underline, f

4条回答
  •  星月不相逢
    2020-12-30 18:36

    there is a example in ApiDemos which can solve your problem. Check out com.example.android.apis.text.Link class, it may help. Following is part of the code:

    TextView t3 = (TextView) findViewById(R.id.text3);
    t3.setText(
            Html.fromHtml(
                "text3:  Text with a " +
                "link " +
                "created in the Java source code using HTML."));
    t3.setMovementMethod(LinkMovementMethod.getInstance());
    

提交回复
热议问题