1

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.
1
  • 1
    You may want to use a SimpleAdapter instead Commented Nov 19, 2012 at 15:35

1 Answer 1

8

@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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.