如何在webview中解析html图像以显示imageview?

时间:2022-09-04 08:14:44

I want to get html image in the webview and display to imageview.

我想在webview中获取html图像并显示到imageview。

I do not want a solution as well as the URL of the picture downloads.

我不想要解决方案以及图片下载的URL。

I have tried the following.

我尝试了以下内容。

public class WebViewClientFix extends WebViewClient
{
    private Bitmap bmpCaptcha;
    private Context context;

    @Override
    public void onReceivedSslError(WebView view, SslErrorHandler handler,SslError error) 
    {
        handler.proceed();
    }

    @Override
    public void onPageFinished(WebView view, String url) 
    {
         super.onPageFinished(view, url);
    }

    @Override
    public void onLoadResource(WebView view, String url) 
    {
        super.onLoadResource(view, url);
    }

        public Bitmap getBmpCaptcha() 
        {
        return bmpCaptcha;
    }

    public void setBmpCaptcha(Bitmap bmpCaptcha) 
    {
        this.bmpCaptcha = bmpCaptcha;
    }

    public Context getContext() {
        return context;
    }

    public void setContext(Context context) {
        this.context = context;
    }
}

and

@Override
protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    webview = (WebView)findViewById(R.id.webView1);
    imageView =   (ImageView)findViewById(R.id.imageView1);

    webview.getSettings().setUseWideViewPort(true);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.getSettings().setAllowFileAccess(true);
    webview.getSettings().setAppCacheEnabled(true);
    webview.getSettings().setLoadsImagesAutomatically(true);
    webClinent = new WebViewClientFix();
    webClinent.setContext(this);
    webview.setWebViewClient(webClinent);
    webview.loadUrl("https://xxxxx.tr/login");      
}

How should I follow a solution?

我该如何解决问题?

thanks

谢谢

1 个解决方案

#1


1  

Fetch the page, parse its content (jsoup might help), identify the image(s) you want, and fetch them.

获取页面,解析其内容(jsoup可能有帮助),识别您想要的图像,并获取它们。

#1


1  

Fetch the page, parse its content (jsoup might help), identify the image(s) you want, and fetch them.

获取页面,解析其内容(jsoup可能有帮助),识别您想要的图像,并获取它们。