【发布时间】:2019-11-06 08:40:51
【问题描述】:
我正在使用“setMovementMethod”在 TextView 上制作可点击的 url。最好看下面的代码:
1. String value = "By signing up, you agree to our <a href=\"https://app.mywebsite.com/terms\">My App Term</a> and confirm that you have read our <a href=\"https://app.mywebsite.com/privacypolicy\">Privacy Policy</a>";
2. TextView text = (TextView) findViewById(R.id.text);
3. text.setText(Html.fromHtml(value));
4. text.setMovementMethod(LinkMovementMethod.getInstance());
问题在于网址的“.com”后面的斜杠。如果我删除那个斜线并像https://app.mywebsite.com那样写网址,那么它可以完美地工作,但是当我写像https://app.mywebsite.com/terms这样的网址时,链接是不可点击的。我可以看到突出显示的链接,但是当单击链接时它不起作用
我该如何解决这个问题?非常感谢。
【问题讨论】:
标签: android url textview clickable