title: android listview nullpointer.exception
body: <p>Im trying to display this listview, but I keep getting a: </p>
  
  <p>07-17 21:14:22.233: ERROR/AndroidRuntime(349): java.lang.NullPointerException</p>
  
  <p>I think I know what the problem is but I dont know how to fix it. </p>
  
  <p>I have a String array which I will be using to be displayed in my list </p>
  
  <pre><code>parser topicparser = new parser();
    final String[] TOPICS = topicparser.topic("http://www.test.com");
  </code></pre>
  
  <p>Dont worry the parser works great. the only problem I see with it is that the parser doesnt know how many strings the website will have so I am setting the String array in the parser to be very big:</p>
  
  <pre><code>String substr[] = new String[250];
  </code></pre>
  
  <p>but I know that mostly there are only like 11 to 13 values that I will be storing in that array, the problem I think is when i do this:</p>
  
  <pre><code>setListAdapter(new ArrayAdapter&lt;String&gt;(this, R.layout.topics, TOPICS));
  
    ListView lv = getListView();
  </code></pre>
  
  <p>since the String array is set to have up to 250 values in it and I only actually store say 12 then there are a null entries so when I run the code it shows me my list view, but when I get to the bottom of the view it force closes and the log tells me that there was nullpointer. I can tell how many entries I collected while I am parsing, but how do I tell my listview to only show say 12 items in the list so there wont be any null entries. or is there any other solution for my problem. </p>
  
  <p>Thank you, </p>
  
  <p>@Cristian C.</p>
  
  <p>I tried doing what you said, but now I am getting a: </p>
  
  <p>java.lang.ClassCastException: java.util.Arrays$ArrayList </p>
  
  <p>this is what I did: </p>
  
  <pre><code>String[] TOPICS = topicparser.topic("test.com"); 
  ArrayList&lt;String&gt; niceArray = (ArrayList&lt;String&gt;) Arrays.asList(TOPICS); // eclipse told me I had to add the cast 
  setListAdapter(new ArrayAdapter&lt;String&gt;(this, R.layout.topics, niceArray)); 
  </code></pre>
  
  <p>any ideas ? Thanks</p>