Search code examples
androidandroid-studiowebviewandroid-webview

Show only certain parts of a web page in a web view, AndroidStudio?


How can I get the certain parts from Website and show in WebView, Android Studio???

Below Image is that I want get part (square in red part) enter image description here

and site is this : https://kimpga.com

I'd like to display only the red part as an Android web view. What should I do?

and then I used this method: webView.loadUrl("javascript:document.getElementsByClassName('').style.display='none'");

but that website doesn't have div id and doesn't work method!

+) add homepage source

Please understand to attach the overall picture. I'd like to show you the part of div selected in blue through a web view.

enter image description here


Solution

  • I solved it!

    using

    mWebView.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(WebView webView, String url)
            {
                webView.loadUrl("javascript:(function() { " +
                        "document.getElementsByClassName(//classname//)[index of document].style.display='none'; " +
                        "})()");
            }
        });