Skip to content Skip to sidebar Skip to footer

Npe While Using Hashmap To Populate Listview

I am creating an android app for a restaurant that lets the waiters take the customers orders. I am using a extended list view to show the menu and have used a hashmap to populate

Solution 1:

One problem could be that you're initializing the adapter after you set it and all items in it are null

Exp_list.setAdapter(adapter);
adapter = newFoodMenuAdapter(this, Food_menu, Food_list);

This might solve the problem:

adapter = newFoodMenuAdapter(this, Food_menu, Food_list);
Exp_list.setAdapter(adapter);

Solution 2:

I think you should initialize the adapter first and then pass it to setadapter.

 adapter = newFoodMenuAdapter(this, Food_menu, Food_list);
 Exp_list.setAdapter(adapter);

Post a Comment for "Npe While Using Hashmap To Populate Listview"