App force closing on button click?
<p>A user may enter an alarm event to happen at a certain time. I have a button that calls all events and displays the time the event will happen. Every time i press on the button even when i set an event before hand, the app force closes. The Logcat points out 3 lines and i have no idea why. </p>

<p>Here is the logcat: </p>

<pre><code>03-11 16:23:15.101: E/AndroidRuntime(13960): java.lang.NullPointerException
03-11 16:23:15.101: E/AndroidRuntime(13960):    at izzy.n.main1.getLastThreeEvents(main1.java:218)
03-11 16:23:15.101: E/AndroidRuntime(13960):    at izzy.n.main1.access$4(main1.java:192)
03-11 16:23:15.101: E/AndroidRuntime(13960):    at izzy.n.main1$4.onClick(main1.java:101)
03-11 16:23:15.101: E/AndroidRuntime(13960):    at android.os.Handler.dispatchMessage(Handler.java:92)
03-11 16:23:15.101: E/AndroidRuntime(13960):    at android.os.Looper.loop(Looper.java:130)
</code></pre>

<p>Here is main1.java I put a link so you can see where each line of code is. <a href="http://codepad.org/7z3Vxq72" rel="nofollow">http://codepad.org/7z3Vxq72</a></p>

<p>And here is main1.xml: </p>

<pre><code>  &lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    &gt;
    &lt;Spinner android:id="@+id/spinner_calendar"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        /&gt;
    &lt;Button android:id="@+id/button_add"
        android:layout_height="wrap_content"
        android:layout_width="150px"
        android:text="Add Event"
        android:layout_gravity="center"
        android:gravity="center"
    /&gt;
    &lt;Button android:id="@+id/button_add2"
        android:layout_height="wrap_content"
        android:layout_width="150px"
        android:text="Add Event 2"
        android:layout_gravity="center"
        android:gravity="center"
    /&gt;
    &lt;Button android:id="@+id/button_get_events"
        android:layout_height="wrap_content"
        android:layout_width="150px"
        android:text="Get Events"
        android:layout_gravity="center"
        android:gravity="center"
    /&gt;
    &lt;TextView  
        android:id="@+id/text_event"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/hello"
        /&gt;
&lt;/LinearLayout&gt;


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