title: Why won't the Back button work in this Android webview?
body: <p>Having problems getting the "Back" button to work in webview.</p>
  
  <p>I'm not sure where in the code I should put the <code>onKeyDown()</code> part (currently under the last <code>@Override</code>)</p>
  
  <p>Both <code>mywebview.canGoBack()</code> and <code>mywebview.goBack()</code> result in errors saying "mywebview cannot be resolved".</p>
  
  <p>If I move the bracket after <code>mywebview.setWebClient(...)</code> all the way to the bottom, <code>mywebview-error</code> goes away, but then <code>override</code>, <code>onKeyDown</code>, <code>return true</code>, and <code>return super</code> result in all kind of errors. </p>
  
  <p>Can anyone tell me what to do?</p>
  
  <p>Code:<br>
  </p>
  
  <pre><code>package com.sib;
  
  import android.os.Bundle;
  import android.app.Activity;
  import android.view.KeyEvent;
  import android.webkit.WebSettings;
  import android.webkit.WebView;
  import android.webkit.WebViewClient;
  
  public class SiB extends Activity {
  
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.sib);
  
          WebView mywebview = (WebView) findViewById(R.id.webview);
          mywebview.loadUrl("url");
  
          WebSettings webSettings = mywebview.getSettings();
          webSettings.setJavaScriptEnabled(true);
  
          mywebview.setWebViewClient(new WebViewClient());
  
      }
  
  
      @Override
      public boolean onKeyDown(int keyCode, KeyEvent event) {
  
          if ((keyCode == KeyEvent.KEYCODE_BACK) &amp;&amp; mywebview.canGoBack()) {
              mywebview.goBack();
              return true;
          }
          return super.onKeyDown(keyCode, event);
      }
  }
  </code></pre>