title: Custom Navigation drawer without ListView and ActionBar
body: <p>I use a navigation drawer in my app, which should look like [this]: <a href="http://godpowerturbo.com/app/uploads/nav.png" rel="nofollow">http://godpowerturbo.com/app/uploads/nav.png</a> [a], now to make it look like the design i have used <code>ImageButton</code> in place of a <code>ListView</code> plus i'm not using Fragments and i open the navigation drawer on a <code>ImageButton</code> click but it exits with a Null Pointer Exception. </p>
  
  <p>I have searched everywhere on Google and StackOverflow but i couldn't fix the error.  </p>
  
  <p>This is the main Activity</p>
  
  <pre><code>   DrawerLayout dw;
     PercentRelativeLayout rl;
     ImageButton nav;    
     @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          Log.d(TAG, "onCreate()");
          Session session = new Session(mCtx);
          Log.e(TAG, "LOG_ID: " + session.getLogId());
          session.putAll();
          rl = (PercentRelativeLayout) findViewById(R.id.nav_left);
          dw = (DrawerLayout) findViewById(R.id.nav_drawer);
          nav = (ImageButton) findViewById(R.id.nav_menu);
          nav.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) { //Opening the drawer returns a Null Pointer Exception
                  Log.e(TAG, "Nav Menu Click!");
                  dw.openDrawer(Gravity.LEFT);
              }
          });
      }
  </code></pre>
  
  <p>Navigation Drawer Layout</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v4.widget.DrawerLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/nav_drawer"
      android:background="@drawable/nav"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;android.support.percent.PercentRelativeLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:app="http://schemas.android.com/apk/res-auto"
          android:id="@+id/nav_left"
          android:paddingLeft="8dp"
          android:paddingTop="65dp"
          android:layout_gravity="left"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
          &lt;ImageButton
              android:background="@android:color/transparent"
              android:layout_alignParentLeft="true"
              android:id="@+id/nav_home"
              android:layout_width="95dp"
              android:layout_height="35dp" /&gt;
  
          &lt;android.support.percent.PercentRelativeLayout
              xmlns:app="http://schemas.android.com/apk/res-auto"
              android:layout_below="@+id/nav_home"
              android:id="@+id/lay_min"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:paddingTop="5dp"
              android:paddingLeft="10dp"&gt;
  
              &lt;ImageButton
                  android:background="@android:color/transparent"
                  android:layout_alignParentLeft="true"
                  android:id="@+id/nav_catalogue"
                  android:layout_width="205dp"
                  android:layout_height="30dp" /&gt;
  
              &lt;ImageButton
                  android:layout_below="@+id/nav_catalogue"
                  android:background="@android:color/transparent"
                  android:layout_alignParentLeft="true"
                  android:id="@+id/nav_upcomingevents"
                  android:layout_width="205dp"
                  android:layout_height="30dp" /&gt;
  
              &lt;ImageButton
                  android:layout_below="@+id/nav_upcomingevents"
                  android:background="@android:color/transparent"
                  android:layout_alignParentLeft="true"
                  android:id="@+id/nav_newlaunch"
                  android:layout_width="205dp"
                  android:layout_height="30dp" /&gt;
  
              &lt;ImageButton
                  android:layout_below="@+id/nav_newlaunch"
                  android:background="@android:color/transparent"
                  android:layout_alignParentLeft="true"
                  android:id="@+id/nav_turbofailure"
                  android:layout_width="205dp"
                  android:layout_height="30dp" /&gt;
  
              &lt;ImageButton
                  android:layout_below="@+id/nav_turbofailure"
                  android:background="@android:color/transparent"
                  android:layout_alignParentLeft="true"
                  android:id="@+id/nav_aboutus"
                  android:layout_width="205dp"
                  android:layout_height="30dp" /&gt;
  
              &lt;ImageButton
                  android:layout_below="@+id/nav_aboutus"
                  android:background="@android:color/transparent"
                  android:layout_alignParentLeft="true"
                  android:id="@+id/nav_enquiry"
                  android:layout_width="205dp"
                  android:layout_height="30dp" /&gt;
  
              &lt;ImageButton
                  android:layout_below="@+id/nav_enquiry"
                  android:background="@android:color/transparent"
                  android:layout_alignParentLeft="true"
                  android:id="@+id/nav_faq"
                  android:layout_width="205dp"
                  android:layout_height="30dp" /&gt;
  
              &lt;ImageButton
                  android:layout_below="@+id/nav_faq"
                  android:background="@android:color/transparent"
                  android:layout_alignParentLeft="true"
                  android:id="@+id/nav_feedback"
                  android:layout_width="205dp"
                  android:layout_height="30dp" /&gt;
  
          &lt;/android.support.percent.PercentRelativeLayout&gt;
  
          &lt;View
              android:id="@+id/lazy_view"
              android:layout_below="@id/lay_min"
              android:background="@android:color/transparent"
              android:layout_width="100dp"
              android:layout_height="130dp" /&gt;
  
          &lt;ImageButton
              android:layout_below="@+id/lazy_view"
              android:background="@android:color/transparent"
              android:layout_alignParentLeft="true"
              android:id="@+id/nav_back"
              android:layout_width="75dp"
              android:layout_height="40dp" /&gt;
  
          &lt;ImageButton
              android:layout_below="@+id/nav_back"
              android:background="@android:color/transparent"
              android:layout_alignParentLeft="true"
              android:id="@+id/nav_exit"
              android:layout_width="75dp"
              android:layout_height="40dp" /&gt;
  
      &lt;/android.support.percent.PercentRelativeLayout&gt;
  
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p>Stack Trace</p>
  
  <pre><code>01-07 20:30:16.708  22258-22258/com.godpowerturbo.android E/Main﹕ Nav Menu Click!
  01-07 20:30:16.708  22258-22258/com.godpowerturbo.android W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x412c0438)
  01-07 20:30:16.738  22258-22258/com.godpowerturbo.android E/AndroidRuntime﹕ FATAL EXCEPTION: main
      java.lang.NullPointerException
              at com.godpowerturbo.android.Main$1.onClick(Main.java:49)
              at android.view.View.performClick(View.java:4084)
              at android.view.View$PerformClick.run(View.java:16987)
              at android.os.Handler.handleCallback(Handler.java:615)
              at android.os.Handler.dispatchMessage(Handler.java:92)
              at android.os.Looper.loop(Looper.java:137)
              at android.app.ActivityThread.main(ActivityThread.java:4807)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:511)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:559)
              at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>Now my problem is when i click the <code>ImageButton</code> crashes the app it raises a <code>Null Pointer Exception</code> when it reaches <code>dw.openDrawer(Gravity.LEFT);</code> the Log before it works. </p>
  
  <p>And how do i access the image button in the Navigation drawer to launch different existing Activities.</p>
  
  <p>Thanks in Advance</p>