【问题标题】:Disable links in WebView in Android [duplicate]在Android中禁用WebView中的链接[重复]
【发布时间】:2013-11-13 12:52:26
【问题描述】:

我知道这有很多,但我想让整个 webview 不可点击,这样就好像你按下图片上的某个地方...

有解决办法吗?

【问题讨论】:

  • 我认为这个话题会有所帮助stackoverflow.com/questions/5116909/…
  • 不,这不是我要搜索的内容,因为使用此代码,我可以单击链接。是的,链接不会打开,但我仍然可以点击它。这就是我不想要的。

标签: android webview hyperlink


【解决方案1】:

好的,所以,也许有一个解决方案。

  • 1:将要显示的内容作为字符串检索
  • 2:查找所有链接(使用 REGEXP)并替换为内容

我不是 REGEXP 方面的专家,但是

<a href="http://www.the-link" alt="ddsd">BLABLA</a>

必须成为

BLABLA

我认为这是可能的

编辑

试试这个功能

private String RemoveUrl(String commentstr)
{
    String commentstr1=commentstr;
    String urlPattern = "((https?|ftp|gopher|telnet|file|Unsure|http):((//)|(\\\\))+[\\w\\d:#@%/;$()~_?\\+-=\\\\\\.&]*)";
    Pattern p = Pattern.compile(urlPattern,Pattern.CASE_INSENSITIVE);
    Matcher m = p.matcher(commentstr1);
    int i=0;
    while (m.find()) {
        commentstr1=commentstr1.replaceAll(m.group(i),"").trim();
        i++;
    }
    return commentstr1;
}

来源:Removing the url from text using java

【讨论】:

  • 谢谢,我试试这个。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多