android listview nullpointer.exception -


I am trying to display this listview, but I am getting it:

07-17 21:14: 22.233: Error / Android Randomime (34 9): java.lang.NullPointerException

I think I know what the problem is, but I'm about to fix it Do not know in

I have a string array that I am using to appear in my list

Last string [] theme = subjectpresor Subject ("http://www.test.com");

Do not worry parser works great The only problem is that parses do not know what the website will be so that I can make the string array too big for parsing:

  string substrate [] = new string [250];  

But I know that most of the 11 to 13 values ​​are what I will store in that array, I think this problem occurs when I do this:

  setListAdapter (new array adapter & lt; string & gt; (this, R.Let.Textics, Topics)); ListView lv = getListView ();  

Because the string array is set to a value of up to 250 and I actually only say 12 so there are blank entries, so when I run the code I see my list view But when I go to the lower part of the scene, it stops the force and the log tells me that the drain indicator was there that I can tell how many entries I collect when I am parsing, but I

Thank you,

@Christian Sea: How to tell your list to show only 12 items in the Survey list, so that there are no blank entries or any other solution for my problem

.

What I said you do, but now I am getting one:

java .lang.ClassCastException: java.util.Arrays $ ArrayList

This I did:

  string [] TOPICS = topicparser.topic ("test.com"); ArrayList & LT; String & gt; GoodReference = (Arreelist & lt; string & gt;) Arrays.asList (TOPICS); // Eclipse told me that I had to add the cast set list adapter (new array adapter & lt; string & gt; (this, R.Late.Texx, nice););  

Any ideas? Thanks

Instead of returning an array of stars in my subject method, I will return a list

Therefore

  string substrate [] = You can write instead of new string [250]  

  ArrayList & LT; String & gt; Substr = New Arrestist & lt; String & gt; ();  

So now you can only use

  substr.add ("whatever string");  

The list will be as large as the items you add, so you will not have to worry about the nullpainter exceptions

and since the topic method now returns An ArrayList, the last part can be rewritten

  nice- themeparser. Subject ("test.com"); SetListAdapter (New Arrayheader & lt; String & gt; (This, R. Late.Texx, Nice));  

Comments