title: Why getting message unfortunately has stopped when adding button click event?
body: <p>Without the button code it's working fine.
  I didn't see anything in the LogCat.</p>
  
  <p>This is the MainActivity.java code:</p>
  
  <pre><code>package com.test.webservertest;
  
  import android.content.Intent;
  import android.net.Uri;
  import android.os.Bundle;
  import android.speech.tts.TextToSpeech;
  import android.speech.tts.TextToSpeech.OnInitListener;
  import android.support.v7.app.ActionBarActivity;
  import android.util.AndroidRuntimeException;
  import android.util.Xml;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.graphics.Canvas;
  import android.graphics.Color;
  import android.graphics.Paint;
  import android.graphics.Path;
  import android.util.AttributeSet;
  import android.view.MotionEvent;
  import android.view.View;
  import android.content.Context;
  import android.view.View.OnClickListener;
  
  import org.apache.http.client.HttpClient;
  import org.apache.http.client.methods.HttpPost;
  import org.apache.http.util.EncodingUtils;
  import org.json.JSONObject;
  import org.json.JSONTokener;
  
  import java.io.DataOutputStream;
  import java.net.HttpURLConnection;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.nio.charset.Charset;
  import java.util.Arrays;
  import java.util.Locale;
  import java.net.URLConnection;
  
  import java.net.HttpURLConnection;
  import java.io.*;
  import java.util.concurrent.Executor;
  import java.util.concurrent.ExecutorService;
  import java.util.concurrent.Executors;
  import java.util.logging.Logger;
  import android.widget.Button;
  
  
  public class MainActivity extends ActionBarActivity
  {
      private static final int MY_DATA_CHECK_CODE = 0;
      public static MainActivity currentActivity;
      TextToSpeech mTts;
      private String targetURL;
      private String urlParameters;
      private Button btnClick;
      private String clicking = "clicked";
  
      @Override
      protected void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          setContentView(new SingleTouchEventView(this, null));
  
          addListenerOnButton();
  
          currentActivity = this;
  
          initTTS();
  
  
      }
  
      public void addListenerOnButton() {
  
          btnClick = (Button) findViewById(R.id.checkipbutton);
  
          btnClick.setOnClickListener(new OnClickListener()
          {
  
              @Override
              public void onClick(View arg0)
              {
  
                  Intent browserIntent =
                          new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.mkyong.com"));
                  startActivity(browserIntent);
  
              }
  
          });
  
      }
  </code></pre>
  
  <p>And in the layout:</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:paddingLeft="@dimen/activity_horizontal_margin"
                  android:paddingRight="@dimen/activity_horizontal_margin"
                  android:paddingTop="@dimen/activity_vertical_margin"
                  android:paddingBottom="@dimen/activity_vertical_margin"
                  tools:context=".MainActivity"&gt;
  
      &lt;TextView
          android:text="WEBSERVER"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerVertical="true"
          android:layout_centerHorizontal="true"
          android:textSize="50dp"
          android:textColor="#FFF"
          android:id="@+id/textView"/&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Check Ip"
          android:id="@+id/checkipbutton"
          android:layout_centerVertical="true"
          android:layout_centerHorizontal="true"/&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>If i'm calling the method: addListenerOnButton(); i'm getting message on the android: unfortunately has stopped and then the program shut down.
  If i'm not calling addListenerOnButton(); then the program will keep working fine.</p>
  
  <p>Also when running the program if not calling the addListenerOnButton(); i don't see the button i added in the layout designer on the screen at all.</p>