【问题标题】:android webview: detect long press on <a> and <img>android webview:检测长按 <a> 和 <img>
【发布时间】:2011-06-22 18:54:22
【问题描述】:

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

【问题讨论】:

    标签: android webview image


    【解决方案1】:

    我查看了 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()) {
            // ...
          }
        }
    

    【讨论】:

    猜你喜欢
    • 2011-12-16
    • 2018-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-04
    相关资源
    最近更新 更多