Hi, I am creating a simple application to display an html page in a webview. I am using webview and showing page load time like this.

After that, turn off the scroll and use the next and previous buttons to save back and forth. So my code is below.
The first onCreate screen adds a webview and loads an html file.
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");
after using the MyWebclient class to get the height and width for mainwebview.
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->"+findHeight); System.err.println("Portait Height->"+protraitHeight); System.err.println("Landscap Height->"+lanscapHeight); } }
after that use myPictureClass to get a webView with a length.
class MyPictureClass implements PictureListener { @Override public void onNewPicture(WebView view, Picture picture) { proTraitContain = mainWebView.getContentHeight(); System.err.println("picture Class Call-->"+proTraitContain); } }
thereafter. Create the next and previous buttons to display the next and previous page. Use the SimpleOnGestureListener app to detect touch.
btnNext = (Button) findViewById(R.id.btnNext); btnNext.setOnTouchListener(this); btnPrev = (Button) findViewById(R.id.btnPrev); btnPrev.setOnTouchListener(this);
Cancel the touch method.
@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 -->"+proTraitContain); System.err.println("Before Height-->" + findHeight); if (btnClickFlage) { if (findHeight > (proTraitContain+protraitHeight)) { if(restProtraitFlag) { System.err.println("If part In side Flag-->"+findHeight); findHeight=findHeight+protraitHeight; restProtraitFlag=false; //findHeight=findHeight+protraitHeight; mainWebView.scrollTo(0, findHeight); System.err.println("If part In side Flag-->"+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<=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-->" + findHeight); } return true; } }
but I cannot show the last page of the current html page. Now what to do. any solution please give. I understand the width of the content correctly and use the scrollTo method to display, but I cannot do this. After the last page of the remainder of some of them can not be displayed.
Please saw me anyway.
Thanks in advance.