title: WebView not working in Android when used with OnClickListener
body: <p>I am working on a simple Android App which uses WebView.</p>
  
  <p>The code is:</p>
  
  <p><strong>activity_main.xml</strong></p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context=".MainActivity"&gt;
  
      &lt;LinearLayout
          android:id="@+id/linear1"
          android:orientation="horizontal"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"&gt;
  
  
          &lt;EditText
              android:id="@+id/editUrl"
              android:layout_weight="3"
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:hint="@string/url_hint"/&gt;
  
          &lt;Button
              android:id="@+id/buttonGo"
              android:layout_weight="1"
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:text="@string/url_go"/&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;WebView
          android:id="@+id/webView1"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_below="@+id/linear1"
          tools:context=".MainActivity" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>public class MainActivity extends ActionBarActivity {
  
      WebView mWebView;
      EditText editText;
      Button button;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          button = (Button)findViewById(R.id.buttonGo);
  
          button.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  editText = (EditText)findViewById(R.id.editUrl);
                  String url = editText.getText().toString();
                  mWebView = (WebView) findViewById(R.id.webView1);
                  mWebView.getSettings().setJavaScriptEnabled(true);
                  mWebView.setWebViewClient(new WebViewClient());
                  mWebView.loadUrl(url);
              }
          });
  
      }
  }
  </code></pre>
  
  <p>However, this code doesn't seem to work. I don't know why. It was working perfectly when I did not add any EditText or Button, and the code in the <strong>MainActivity.java</strong> was:</p>
  
  <pre><code>public class MainActivity extends ActionBarActivity {
  
      WebView mWebView;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
                  String url = "http://google.com";
  
                  mWebView = (WebView) findViewById(R.id.webView1);
                  mWebView.getSettings().setJavaScriptEnabled(true);
                  mWebView.setWebViewClient(new WebViewClient());
                  mWebView.loadUrl(url);
              }
          });
  
      }
  }
  </code></pre>
  
  <p>I have no idea why this is happening because the app seemed to work fine before.
  When I changed the layout, the app doesn't work.</p>
  
  <p>Please help me in detail as I am new to Android.</p>
  
  <p>Thanks.</p>
  
  <p><strong>PLEASE FEEL FREE TO SUGGEST ME A BETTER METHOD TO IMPLEMENT THIS ALSO</strong></p>