title: How to change WebView content on Button click in Android?
body: <p>I am implementing a small project in which I'm diplaying a local image in my webview (in order to use the Zooming &amp; Panning functionality), and on a button click the Next Image will be loaded.
  I'm able to load the image, but on the Button click I'm unable to reload the webview with the new image.</p>
  
  <p>Any suggestions will really helpful. :)</p>
  
  <p>Below is my WebViewActivity.java code:</p>
  
  <pre><code>/** Called when the activity is first created. */
  
  
  @Override
  public void onCreate(Bundle savedInstanceState) 
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.web_view_activity);
  
      // Initialize all View Components
  
      flippy = (ViewFlipper)findViewById(R.id.viewFlipper1);
      WebView mWebView = (WebView) findViewById(R.id.webView);
      next = (ImageButton)findViewById(R.id.next);
      next.setAlpha(100);
      previous = (ImageButton)findViewById(R.id.previous);
      previous.setAlpha(100);
  
  
      mWebView.setInitialScale(0);
      WebSettings webSettings = mWebView.getSettings();
      webSettings.setUseWideViewPort(true);
  
  
      mWebView.getSettings().setJavaScriptEnabled(true);
      mWebView.loadUrl("file:///android_asset/start.png");
      mWebView.getSettings().setBuiltInZoomControls(true);
  
  
  
  }
  
  public void onClickFeature (View v)
  {
      int id = v.getId ();
      switch (id) {
      case R.id.next :    
              imagename = /*nextImagename*/;
             mWebView.loadUrl(imagename)
                 flippy.showNext();
              break;
  
      case R.id.previous:
              imagename = /*previousImagename*/;
      mWebView.loadUrl(imagename)
          flippy.showNext();
      break;
      default:
      break;
  }
  }
  </code></pre>
  
  <p>Following is the web_view_activity.xml</p>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" &gt;
  
  &lt;ViewFlipper
           android:id="@+id/viewFlipper1"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent" &gt;
  
      &lt;WebView
          android:id="@+id/webView"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent" /&gt;
  
  &lt;/ViewFlipper&gt;
  
  
      &lt;ImageButton
          android:id="@+id/previous"
          android:layout_width="59dp"
          android:layout_height="wrap_content"
          android:layout_gravity="center|left"
          android:background="@null"
          android:onClick="onClickFeature"
          android:src="@drawable/previous" /&gt;
  
  
      &lt;ImageButton
          android:id="@+id/next"
          android:layout_width="59dp"
          android:layout_height="wrap_content"
          android:layout_gravity="center|right"
          android:background="@null"
          android:onClick="onClickFeature"
          android:src="@drawable/next" /&gt;
  </code></pre>
  
  <p></p>