Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Display the Html content page wise using webview in android?
    text
    copied!<p>hi i create simple app to display html page in webview i use the webview and display the page load time like this.</p> <p><img src="https://i.stack.imgur.com/qXLRF.png" alt="Display first time load the data"></p> <p>After this Disable the scroll and use the next and previous button to back and forward contain. So my code is below.</p> <p>First onCreate display add webview and load the html file.</p> <pre><code> mainWebView = (WebView) findViewById(R.id.mainWebView); mainWebView.setVerticalScrollBarEnabled(false); mainWebView.setHorizontalScrollBarEnabled(false); mainWebView.getSettings().setJavaScriptEnabled(true); mainWebView.setWebViewClient(new MyWebClient()); mainWebView.setPictureListener(new MyPictureClass()); mainWebView.loadUrl("file:///android_asset/chapter-001.html"); </code></pre> <p><strong>after use the MyWebclient Class for get the Height and width for mainwebview.</strong></p> <pre><code>class MyWebClient extends WebViewClient { @Override public void onPageFinished(WebView view, String url) { System.err.println("Page Finish Call"); lanscapHeight = protraitHeight = findHeight = mainWebView.getHeight(); System.err.println("Find Height-&gt;"+findHeight); System.err.println("Portait Height-&gt;"+protraitHeight); System.err.println("Landscap Height-&gt;"+lanscapHeight); } } </code></pre> <p>after this use the myPictureClass to get the webView contain length.</p> <pre><code>class MyPictureClass implements PictureListener { @Override public void onNewPicture(WebView view, Picture picture) { proTraitContain = mainWebView.getContentHeight(); System.err.println("picture Class Call--&gt;"+proTraitContain); } } </code></pre> <p><strong>after this.create button next and previous to display the next and previous page.so use the SimpleOnGestureListener to Detect touch event.</strong></p> <pre><code> btnNext = (Button) findViewById(R.id.btnNext); btnNext.setOnTouchListener(this); btnPrev = (Button) findViewById(R.id.btnPrev); btnPrev.setOnTouchListener(this); </code></pre> <p>Override touch Method.</p> <pre><code> @Override public boolean onTouch(View view, MotionEvent event) { if (view == btnNext) { btnClickFlage = true; gestureDetector.onTouchEvent(event); } else { btnClickFlage = false; gestureDetector.onTouchEvent(event); } return false; } implement the SimpleGestureListener class as Below. class MyGesture extends SimpleOnGestureListener { @Override public boolean onSingleTapUp(MotionEvent e) { super.onSingleTapUp(e); System.err.println("Display Total Contain For Protrait --&gt;"+proTraitContain); System.err.println("Before Height--&gt;" + findHeight); if (btnClickFlage) { if (findHeight &gt; (proTraitContain+protraitHeight)) { if(restProtraitFlag) { System.err.println("If part In side Flag--&gt;"+findHeight); findHeight=findHeight+protraitHeight; restProtraitFlag=false; //findHeight=findHeight+protraitHeight; mainWebView.scrollTo(0, findHeight); System.err.println("If part In side Flag--&gt;"+findHeight); }else { mainWebView.loadUrl("file:///android_asset/chapter-002.html"); restProtraitFlag=true; } } else { if(protraitFlag) { if(findHeight==protraitHeight) { findHeight = protraitHeight; }else { findHeight = findHeight + protraitHeight; } protraitFlag=false; }else { findHeight = findHeight + protraitHeight; } mainWebView.scrollTo(0, findHeight); } } else { restProtraitFlag=true; if (findHeight&lt;=0) { mainWebView.loadUrl("file:///android_asset/chapter-001.html"); System.err.println("Load Previous page"); } else { findHeight = findHeight - protraitHeight; mainWebView.scrollTo(0, findHeight); } } System.err.println("After Height--&gt;" + findHeight); } return true; } } </code></pre> <p>but i can't Display the last page of current html page path.now what to do.any solution please give.it's urgent. i get the content width properly and use the scrollTo method to display but i can't do it.after last page rest of some contain can't display.</p> <p>Please saw me the any way.</p> <p>Thank in advance..</p>
 

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