title: NullPointerException when initializing NavigationDrawer
body: <p>I'm trying to use a <code>Navagation Drawer</code> in my application and I keep running into NullPointerExceptions and I don't understand why. My current code which is based largely off of <a href="http://developer.android.com/training/implementing-navigation/nav-drawer.html" rel="nofollow">this developer link</a> is: </p>
  
  <pre><code>public class MainActivity extends Activity {
  private String[] mPages;
  private DrawerLayout mDrawerLayout;
  private ListView mDrawerList;
  private ActionBarDrawerToggle mDrawerToggle;
  private CharSequence mDrawerTitle;
  private CharSequence mTitle;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      mPages = getResources().getStringArray(R.array.page_titles);
      mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
      mDrawerList = (ListView) findViewById(R.id.left_drawer);
      mDrawerList.setAdapter(new ArrayAdapter&lt;String&gt;(this,
              R.layout.drawer_list_item, mPages));
  
      mTitle = mDrawerTitle = getTitle();
      mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
      mDrawerToggle = new ActionBarDrawerToggle(this, 
      mDrawerLayout,
      R.drawable.ic_drawer, 
      R.string.drawer_open, 
      R.string.drawer_close 
      ) {
  
  
          public void onDrawerClosed(View view) {
              getActionBar().setTitle(mTitle);
          }
  
  
          public void onDrawerOpened(View drawerView) {
              getActionBar().setTitle(mDrawerTitle);
          }
      };
  
  
      mDrawerLayout.setDrawerListener(mDrawerToggle);
  
      getActionBar().setDisplayHomeAsUpEnabled(true);
      getActionBar().setHomeButtonEnabled(true);
  }
  
  @Override
  protected void onPostCreate(Bundle savedInstanceState) {
      super.onPostCreate(savedInstanceState);
      // Sync the toggle state after onRestoreInstanceState has occurred.
      mDrawerToggle.syncState();
  }
  
  @Override
  public void onConfigurationChanged(Configuration newConfig) {
      super.onConfigurationChanged(newConfig);
      mDrawerToggle.onConfigurationChanged(newConfig);
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
  
      if (mDrawerToggle.onOptionsItemSelected(item)) {
          return true;
      }
  
      return super.onOptionsItemSelected(item);
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  
  }
  </code></pre>
  
  <p>and my drawer_layout.xml:</p>
  
  <pre><code>&lt;android.support.v4.widget.DrawerLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/drawer_layout"
  android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
  &lt;!-- The main content view --&gt;
  &lt;FrameLayout
      android:id="@+id/content_frame"
      android:layout_width="match_parent"
      android:layout_height="match_parent" /&gt;
  &lt;!-- The navigation drawer --&gt;
  &lt;ListView android:id="@+id/left_drawer"
      android:layout_width="240dp"
      android:layout_height="match_parent"
      android:layout_gravity="start"
      android:choiceMode="singleChoice"
      android:divider="@android:color/transparent"
      android:dividerHeight="0dp"
      android:background="#111"/&gt;
  </code></pre>
  
  <p></p>
  
  <p>My stacktrace: </p>
  
  <pre><code>08-12 15:55:54.524: E/AndroidRuntime(1409): FATAL EXCEPTION: main
  08-12 15:55:54.524: E/AndroidRuntime(1409): java.lang.RuntimeException:     Unable to start activity     ComponentInfo{com.test.android.nav/com.test.android.nav.MainActivity}:     java.lang.NullPointerException
  08-12 15:55:54.524: E/AndroidRuntime(1409):     at     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
  08-12 15:55:54.524: E/AndroidRuntime(1409):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
  08-12 15:55:54.524: E/AndroidRuntime(1409):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
  08-12 15:55:54.524: E/AndroidRuntime(1409):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
  08-12 15:55:54.524: E/AndroidRuntime(1409):     at android.os.Handler.dispatchMessage(Handler.java:99)
  08-12 15:55:54.524: E/AndroidRuntime(1409):     at android.os.Looper.loop(Looper.java:137)
  08-12 15:55:54.524: E/AndroidRuntime(1409):     at android.app.ActivityThread.main(ActivityThread.java:4745)
  08-12 15:55:54.524: E/AndroidRuntime(1409):     at java.lang.reflect.Method.invokeNative(Native Method)
  08-12 15:55:54.524: E/AndroidRuntime(1409):     at java.lang.reflect.Method.invoke(Method.java:511)
  08-12 15:55:54.524: E/AndroidRuntime(1409):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
  08-12 15:55:54.524: E/AndroidRuntime(1409):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  08-12 15:55:54.524: E/AndroidRuntime(1409):     at dalvik.system.NativeStart.main(Native Method)
  08-12 15:55:54.524: E/AndroidRuntime(1409): Caused by: java.lang.NullPointerException
  08-12 15:55:54.524: E/AndroidRuntime(1409):     at com.test.android.nav.MainActivity.onCreate(MainActivity.java:30)
  08-12 15:55:54.524: E/AndroidRuntime(1409):     at android.app.Activity.performCreate(Activity.java:5008)
  08-12 15:55:54.524: E/AndroidRuntime(1409):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
  08-12 15:55:54.524: E/AndroidRuntime(1409):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
  08-12 15:55:54.524: E/AndroidRuntime(1409):     ... 11 more
  </code></pre>
  
  <p>line 30 is : <code>mDrawerList.setAdapter(new ArrayAdapter&lt;String&gt;(this,
                  R.layout.drawer_list_item, mPages));</code> and I do have that as an xml file in my res folder. </p>
  
  <p>Now, before I put in that line, I was getting a <code>NullPointerException</code> on this line: <code>mDrawerLayout.setDrawerListener(mDrawerToggle);</code></p>
  
  <p>Any help would be much appreciated!</p>