Note that there are some explanatory texts on larger screens.

plurals
  1. POviewpager + webview, how to stop webview loading
    primarykey
    data
    text
    <p>Hi,</p> <p>I have created an app that uses ViewPager and all pages contain WebViews. Every Webview contains server images, videos, mp3 ...</p> <p>The WebView settings are </p> <pre><code> public Object instantiateItem(View collection, int position) { . . . final RelativeLayout imageLayout = (RelativeLayout) inflater.inflate(R.layout.omb_webview_layout, null); WebView webview = (WebView) imageLayout.findViewById(R.id.video_view); ProgressBar pbImage = (ProgressBar) imageLayout.findViewById(R.id.progressBar1); webview.requestFocus(View.FOCUS_DOWN); webview.getSettings().setBuiltInZoomControls(false); webview.getSettings().setSupportZoom(true); webview.getSettings().setUseWideViewPort(true); webview.getSettings().setJavaScriptEnabled(true); webview.getSettings().setLoadWithOverviewMode(true); webview.getSettings().setUseWideViewPort(true); webview.setWebViewClient(new mWebViewClient()); webview.getSettings().setPluginsEnabled(true); webview.clearCache(true); webview.clearHistory(); if(Pbar != null) { webview.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView view, int progress) { Log.i(TAG, "webview loading progress : "+ progress); if(progress == 100) { try { Pbar.setVisibility(ProgressBar.GONE); } catch (Exception e) { Log.e(TAG, "timer progress GONE : "+ progress,e); } } }); } </code></pre> <p>The problem is when pages are swiped then also this line </p> <pre><code> Log.i(TAG, "webview loading progress : "+ progress); </code></pre> <p>is executing which means that webviews are loading in background. If I swipe 4 or more pages all webviews are loading.</p> <pre><code> destroyItem(View collection, int position, Object o) { Log.d("DESTROY", "destroying view at position sheetal " + position); RelativeLayout view = (RelativeLayout)o; WebView tmp = webviewDictionary.get(position);; tmp.getSettings().setJavaScriptEnabled(false); tmp.stopLoading(); if(tmp != null){ Log.i(TAG, "sheetal webview is destroyed " +position ); try { tmp.onPause(); tmp.loadDataWithBaseURL("about:blank", "&lt;html&gt;&lt;/html&gt;","text/html", "UTF-8", null); tmp=null; // tmp.destroy(); } catch (Exception e) { Log.i(TAG, "webview destroyed Exception 0" ,e); } } </code></pre> <p>How to stop background loading if the pages are not visible? setOffscreenPageLimit(1)(means 3 page prev,cur,next),</p> <p>In Viewpager, 2 page (means 1 position page) is not loading properly. It shows a blank white page, how do I solve it?</p> <p>Thanks in advance </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload