android webview:检测长按<a> and <img/></a>

时间:2011-02-07 14:32:34

标签: android webview image

有没有办法检测WebView中链接和图像的长按?

1 个答案:

答案 0 :(得分:9)

我查看了Browser.apk源代码,找到了我真正想要的内容:

    public void onCreate(Bundle savedInstanceState) {
        // ...
        registerForContextMenu(descriptionWebView);
        // ...
    }

    public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
      WebView.HitTestResult hitTestResult = descriptionWebView.getHitTestResult();
      switch (hitTestResult.getType()) {
        // ...
      }
    }