title: NullPointerException setOnClickListner
body: <p>I'm beginner of android.
  This is the code I copy from a book. But when I download and run on my smartphone the NullPointerException occurs.</p>
  
  <p>The information of the exception as below:</p>
  
  <p>java.lang.NullPointerExcption:Attempt to invoke virtual method'void android.widget.Button.setOnClickListner on a null object reference at ....</p>
  
  <p>this is part of my code:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      Button btn1 , btn2;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
         // requestWindowFeature(Window.FEATURE_PROGRESS);
          requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
          btn1 = (Button) findViewById(R.id.btn1);
          btn2 = (Button) findViewById(R.id.btn2);
          btn1.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  setProgressBarIndeterminateVisibility(true);
                  setProgressBarVisibility(true);
                  setProgress(4500);
              }
          });
          btn2.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  setProgressBarIndeterminateVisibility(false);
                  setProgressBarVisibility(false);
              }
          });
          setContentView(R.layout.activity_main);
  
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
  
          FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
          fab.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                          .setAction("Action", null).show();
              }
          });
      }
  </code></pre>
  
  <p>And here is the XML file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      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"
      app:layout_behavior="@string/appbar_scrolling_view_behavior"
      tools:context="com.neoncowboy.titleprogressbar.MainActivity"
      tools:showIn="@layout/activity_main"
      android:orientation="horizontal"&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="显示"
          android:id="@+id/btn1" /&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="隐藏"
          android:id="@+id/btn2" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>