Android & Wordpress Help center

Android: WebView, enable / disable navigation buttons

A very convenient way of changing the state of navigation buttons [forward / back button] of a webview as enabled and disabled as per the availability of next and previous pages is to add this function in your code, and call it from onPageFinished() method of your WebViewClient class.

Code snippet:

mWebView.setWebViewClient(new MyWebViewClient());

public class MyWebViewClient extends WebViewClient{
   public void onPageFinished(WebView view, String url) {
         super.onPageFinished(view, url);


   public void onPageStarted(WebView view, String url, Bitmap favicon) {
     super.onPageStarted(view, url, favicon);

   public void onReceivedError(WebView view, int errorCode,
     String description, String failingUrl) {
     super.onReceivedError(view, errorCode, description, failingUrl);

    public boolean shouldOverrideUrlLoading(WebView view, String url) {
      return super.shouldOverrideUrlLoading(view, url);


* Changes state of navigation buttons – Disable / Enable as per
* the availability of previous / next pages.
public void enableDisableNavigationButtons(WebView mWebView) {
// if has previous page, enable the back button

// if has next page, enable the next button



Single Post Navigation

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: