title: List Activity Null Pointer Exception. Force Close on Emulator Start Up
body: <p>Here is the code for my ListActivity:</p>
  
  <pre><code>    public class CornellRSS extends ListActivity {
      private final static String rssUrl = "http://news.cornellcollege.edu/rss";
      RSSParser parser;
      ArrayList&lt;Message&gt; messages;
      private ProgressDialog pd;
      public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      //setContentView(R.layout.main);
      messages = new ArrayList&lt;Message&gt;();
      parser = new RSSParser(rssUrl);
      loadMessages();
      String[] titles = new String[messages.size()];
      this.setListAdapter(new ArrayAdapter&lt;String&gt;(this,
              android.R.layout.simple_list_item_1, titles));
      ListView lv = getListView();
      lv.setTextFilterEnabled(true);
  
      lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView&lt;?&gt; parent, View view,
            int position, long id) {
          // When clicked, show a toast with the TextView text
          String keyword = (String) ((TextView) view).getText();
          Message target = getMessage(keyword);
          Bundle b = new Bundle();
          b.putString(RSSHandler.TITLE, target.getTitle());
          b.putString(RSSHandler.DESCRIPTION, target.getTitle());
          b.putString(RSSHandler.LINK, target.getTitle());
          b.putString(RSSHandler.PUB_DATE, target.getTitle());
          Intent intent = new Intent(view.getContext(), RSSFeed.class);
          intent.putExtras(b);
          startActivity(intent);
        }
      });
  
  }
  </code></pre>
  
  <p>I keep getting the null pointer exception and can't find a solution. Any help?</p>
  
  <p>EDIT!</p>
  
  <p>The arraylist messages is modified in the method load messages.
  The LogCat message at the top is just: "09-28 01:45:06.726: ERROR/AndroidRuntime(755): java.lang.NullPointerException"</p>
  
  <blockquote>
    <p>The full error is: 09-28 01:45:06.726: ERROR/AndroidRuntime(755):
    FATAL EXCEPTION: main 09-28 01:45:06.726: ERROR/AndroidRuntime(755):
    java.lang.NullPointerException 09-28 01:45:06.726:
    ERROR/AndroidRuntime(755):     at
    android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:355)
    09-28 01:45:06.726: ERROR/AndroidRuntime(755):     at
    android.widget.ArrayAdapter.getView(ArrayAdapter.java:323) 09-28
    01:45:06.726: ERROR/AndroidRuntime(755):     at
    android.widget.AbsListView.obtainView(AbsListView.java:1430) 09-28
    01:45:06.726: ERROR/AndroidRuntime(755):     at
    android.widget.ListView.makeAndAddView(ListView.java:1745) 09-28
    01:45:06.726: ERROR/AndroidRuntime(755):     at
    android.widget.ListView.fillDown(ListView.java:670) 09-28
    01:45:06.726: ERROR/AndroidRuntime(755):     at
    android.widget.ListView.fillFromTop(ListView.java:727) 09-28
    01:45:06.726: ERROR/AndroidRuntime(755):     at
    android.widget.ListView.layoutChildren(ListView.java:1598) 09-28
    01:45:06.726: ERROR/AndroidRuntime(755):     at
    android.widget.AbsListView.onLayout(AbsListView.java:1260) 09-28
    01:45:06.726: ERROR/AndroidRuntime(755):     at
    android.view.View.layout(View.java:7175) 09-28 01:45:06.726:
    ERROR/AndroidRuntime(755):     at
    android.widget.FrameLayout.onLayout(FrameLayout.java:338) 09-28
    01:45:06.726: ERROR/AndroidRuntime(755):     at
    android.view.View.layout(View.java:7175) 09-28 01:45:06.726:
    ERROR/AndroidRuntime(755):     at
    android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
    09-28 01:45:06.726: ERROR/AndroidRuntime(755):     at
    android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
    09-28 01:45:06.726: ERROR/AndroidRuntime(755):     at
    android.widget.LinearLayout.onLayout(LinearLayout.java:1047) 09-28
    01:45:06.726: ERROR/AndroidRuntime(755):     at
    android.view.View.layout(View.java:7175) 09-28 01:45:06.726:
    ERROR/AndroidRuntime(755):     at
    android.widget.FrameLayout.onLayout(FrameLayout.java:338) 09-28
    01:45:06.726: ERROR/AndroidRuntime(755):     at
    android.view.View.layout(View.java:7175) 09-28 01:45:06.726:
    ERROR/AndroidRuntime(755):     at
    android.view.ViewRoot.performTraversals(ViewRoot.java:1140) 09-28
    01:45:06.726: ERROR/AndroidRuntime(755):     at
    android.view.ViewRoot.handleMessage(ViewRoot.java:1859) 09-28
    01:45:06.726: ERROR/AndroidRuntime(755):     at
    android.os.Handler.dispatchMessage(Handler.java:99) 09-28
    01:45:06.726: ERROR/AndroidRuntime(755):     at
    android.os.Looper.loop(Looper.java:123) 09-28 01:45:06.726:
    ERROR/AndroidRuntime(755):     at
    android.app.ActivityThread.main(ActivityThread.java:3683) 09-28
    01:45:06.726: ERROR/AndroidRuntime(755):     at
    java.lang.reflect.Method.invokeNative(Native Method) 09-28
    01:45:06.726: ERROR/AndroidRuntime(755):     at
    java.lang.reflect.Method.invoke(Method.java:507) 09-28 01:45:06.726:
    ERROR/AndroidRuntime(755):     at
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    09-28 01:45:06.726: ERROR/AndroidRuntime(755):     at
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 09-28
    01:45:06.726: ERROR/AndroidRuntime(755):     at
    dalvik.system.NativeStart.main(Native Method) 09-28 01:45:08.624:
    ERROR/InputDispatcher(72): channel '4093eaf0 cc.rss/cc.rss.CornellRSS
    (server)' ~ Consumer closed input channel or an error occurred. 
    events=0x8 09-28 01:45:08.636: ERROR/InputDispatcher(72): channel
    '4093eaf0 cc.rss/cc.rss.CornellRSS (server)' ~ Channel is
    unrecoverably broken and will be disposed!</p>
  </blockquote>
  
  <p>Sorry for not making this available sooner.</p>