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 = new FoodMenuAdapter(this, Food_menu, Food_list);

This might solve the problem:

adapter = new FoodMenuAdapter(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 = new FoodMenuAdapter(this, Food_menu, Food_list);
 Exp_list.setAdapter(adapter);

Post a Comment for "NPE While Using HashMap To Populate ListView"