Reputation: 31
Can we set an ArrayList
containing HashMap
into an ArrayAdapter
?
i am using
ArrayAdapter<ArrayList<HashMap<String, String>>> ad=
new ArrayAdapter<ArrayList<HashMap<String,String>>>(this, android.R.layout.simple_list_item_1,items);
but this gives me an error saying
The constructor ArrayAdapter<ArrayList<HashMap<String,String>>>(searchname, int, ArrayList<HashMap<String,String>>) is undefined.
Upvotes: 1
Views: 5095
Reputation: 579
@nikhil you can you use below code, as this works for me.
ArrayList<HashMap<String, String>> inviteList = new ArrayList<HashMap<String, String>>();
for(int i=0;i < inviteListRespone.size();i++)
{
map = new HashMap<String, String>();
map.put("id",String.valueOf(i));
map.put("emailID", inviteListRespone.get(i).getEmail());
inviteList.add(map);
}
adapter = new SimpleAdapter(context, inviteList, R.layout.invite_list_view,
new String[] { "emailID" },new int[]{R.id.inviteTextView});
listBoth.setAdapter(adapter);
Upvotes: 8