Reputation: 1433
I am just trying to fill my ListView but I get a NullPointerException
Here is the code
String[] values = new String[] { "Reset Company", "Reset Demographic"};
ArrayAdapter<String> adapter = new ArrayAdapter<String(this,android.R.layout.simple_list_item_1, values);
settingsOptions.setAdapter(adapter);
The LogCat says there is a NullPointException on this line settingsOptions.setAdapter(adapter);
How can i resolve this?
Upvotes: 0
Views: 70
Reputation: 15701
as per The LogCat says there is a NullPointException on this line settingsOptions.setAdapter(adapter);
it looks settingsOptions is null there .
Upvotes: 0
Reputation: 81349
You can resolve it by giving settingsOptions
a valid value instead of null
.
Chances are you are doing a findViewById
with an invalid id, or before the view is actually put there by setContentView
.
Upvotes: 2