nullpointer because of toggle button?
<p>I use this code to set the view</p>

<pre><code> setContentView(R.layout.main_activity);
</code></pre>

<p>and i then i have this code to get infromation up on screen</p>

<pre><code> Cursor MainPageCursor = databaseHelper.fetchAllReminders();
     startManagingCursor(MainPageCursor);


     String[] empty = new String[] { DatabaseStore.MUTE_TITLE,  DatabaseStore.START_KEY_TIME, DatabaseStore.END_KEY_TIME, DatabaseStore.COVERT_DAYS }; 



        int[] notempty = new int[]{R.id.text1,R.id.text2, R.id.text4,  R.id.text5};
        SimpleCursorAdapter mainPageList = new SimpleCursorAdapter(this, R.layout.editinfo_row,MainPageCursor, empty, notempty);
       setListAdapter(mainPageList); 
</code></pre>

<p>but the problem i have is i need to get a toggle button into each item row in the simplecursoradapter but if i put it into the simplecursoradapter layout R.layout.editinfo_row i get a nullpointer exception how do i fix that?</p>

<p>update - editinfo_row.xml</p>

<pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/widget38"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginLeft="10dip"
        android:layout_marginRight="10dip"
        android:orientation="vertical" &gt;

        &lt;TextView
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/text1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:textSize="25sp" /&gt;

        &lt;LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal" &gt;


            &lt;TextView
                android:id="@+id/text2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="30sp" /&gt;
    &lt;TextView
                android:id="@+id/text3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text=" - "
                android:textSize="30sp" /&gt;
            &lt;TextView
                android:id="@+id/text4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="30sp" /&gt;


        &lt;ToggleButton
        android:id="@+id/toggleButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
          android:textOn="main"
        android:textOff="off"
        android:text="ToggleButton" /&gt;

&lt;/LinearLayout&gt;



  &lt;LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal" &gt;
            &lt;TextView
                android:id="@+id/text5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="15sp" /&gt;

        &lt;/LinearLayout&gt;

    &lt;/LinearLayout&gt;
</code></pre>

<p>logcat:</p>

<pre><code>05-30 16:31:14.249: E/AndroidRuntime(21484): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.seanoneill.android.SilentPhone/com.seanoneill.android.SilentPhone.MainActivity}: java.lang.NullPointerException
05-30 16:31:14.249: E/AndroidRuntime(21484):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
05-30 16:31:14.249: E/AndroidRuntime(21484):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
05-30 16:31:14.249: E/AndroidRuntime(21484):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-30 16:31:14.249: E/AndroidRuntime(21484):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
05-30 16:31:14.249: E/AndroidRuntime(21484):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-30 16:31:14.249: E/AndroidRuntime(21484):    at android.os.Looper.loop(Looper.java:123)
05-30 16:31:14.249: E/AndroidRuntime(21484):    at android.app.ActivityThread.main(ActivityThread.java:3729)
05-30 16:31:14.249: E/AndroidRuntime(21484):    at java.lang.reflect.Method.invokeNative(Native Method)
05-30 16:31:14.249: E/AndroidRuntime(21484):    at java.lang.reflect.Method.invoke(Method.java:507)
05-30 16:31:14.249: E/AndroidRuntime(21484):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:874)
05-30 16:31:14.249: E/AndroidRuntime(21484):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:632)
05-30 16:31:14.249: E/AndroidRuntime(21484):    at dalvik.system.NativeStart.main(Native Method)
05-30 16:31:14.249: E/AndroidRuntime(21484): Caused by: java.lang.NullPointerException
05-30 16:31:14.249: E/AndroidRuntime(21484):    at com.seanoneill.android.SilentPhone.MainActivity.addListenerOnButton(MainActivity.java:190)
05-30 16:31:14.249: E/AndroidRuntime(21484):    at com.seanoneill.android.SilentPhone.MainActivity.onCreate(MainActivity.java:47)
05-30 16:31:14.249: E/AndroidRuntime(21484):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-30 16:31:14.249: E/AndroidRuntime(21484):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
05-30 16:31:14.249: E/AndroidRuntime(21484):    ... 11 more
</code></pre>
