Android TextView Hyperlink

前端 未结 8 744
悲&欢浪女
悲&欢浪女 2021-02-05 03:45

I\'m implementing a TextView with a string containing two hyperlinks as below but the links are not opening a new browser window:



        
8条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-05 04:11

    Have a look on below code snippet, hope it helps,

    TextView textView =(TextView)findViewById(R.id.textView);
    textView.setClickable(true);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    String text = " Google ";
    textView.setText(Html.fromHtml(text));
    

提交回复
热议问题