Hi guys
I am using a custom ArrayAdapter in order to populate a ListView in my page. This is the initation code of that adapter:
public IngredientListAdapter(Context context, int layout_resourceid, ArrayList<RecipeItem> items) {
super(context, layout_resourceid);
this.items = items ;
ctx = context;
}
To this array adapter, I pass an array of RecipeItems (inside my ListRecipeItems ListActivity class) as such:
iAd = new IngredientListAdapter(this, R.layout.recipeitem_row, recipe.Ingredients );
this.setListAdapter(iAd) ;
However, I find that the ListView is not populated, despite the recipe.Ingredients ArrayList definitely being populated correctly.
A check of iAd.items.getCount() confirms that the items are there. The only way that I can get the ListView to populate is by then manually adding each item to it with .add() e.g.;
for(int i=0;i<recipe.Ingredients.size();i++)
{
iAd.add(recipe.Ingredients.get(i));
}
My understanding was that passing a full array to the ArrayAdapter on initialization would automatically populate that ListView. However it seems that the getView method of the Adapater is never being called.
Could anyone shed any light on this behaviour? I am pretty new to android and java so I may have missed something obvious.
Many thanks Nick