gethittestresult()上的WebView图像返回null [英] gethittestresult() returning null on images in webview

查看:1807
本文介绍了gethittestresult()上的WebView图像返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Im做一个webview.I一个getHitTestResult()想要得到的图像的URL点击。这似乎是工作的罚款与锚,但不与图像。我总是用图像的空。所以我甚至尝试requestFocusNodeHref(消息m)。仍然没有网址!

所以我该怎么办?

  this.setOnLongClickListener(新OnLongClickListener(){
        @覆盖
        公共布尔onLongClick(视图v){            的WebView的WebView =(的WebView)V;
            WebView.HitTestResult导致= webview.getHitTestResult();
            Log.d(MP,与字符串>中+ result.toString());
            Log.d(MP,型 - >中+ result.getType());
            Log.d(MP,URL->中+ result.getExtra());
        }


解决方案

根据文档的结果类型为IMAGE_TYPE只有当HTML内容是由img标签否则它将返回其他值。所以你不能在那个时候得到的URL时,结果类型为IMAGE_TYPE

Im doing a getHitTestResult() on a webview.I want to get the url of the image clicked on. it seems to be working fine with anchors, but not with images. i always get a null with images. so i even tried requestFocusNodeHref(Message m). still no url!

so what do i do?

        this.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {

            WebView webview = (WebView) v;
            WebView.HitTestResult result = webview.getHitTestResult();
            Log.d("MP","String->"+result.toString());
            Log.d("MP","Type->"+result.getType());
            Log.d("MP","URL->"+result.getExtra());
        }

解决方案

As per the documentation the result type is IMAGE_TYPE only when the HTML content consist the img tag else it will return other value. So you can not get the URL at that time when the result type is IMAGE_TYPE

这篇关于gethittestresult()上的WebView图像返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆