Top Picks

Amazon

4.4163556

 

FREE

Bible

4.6847515

 

FREE
   
December 1, 2012

 

populating Listview with arrayadapter<HashMap<String, String>>

 

I am using following code but it does not populates the listview.

ArrayList<HashMap<String, String>> menuItems = new ArrayList<HashMap<String, String>>(); lv.setAdapter(new ArrayAdapter<HashMap<String, String>> (this,android.R.layout.simple_list_item_1 , menuItems));

The problem is the above code creates adapter successfully but it does not show in listview.

Thank you

 

Answer

You can implement SimpleAdapter for filling data from ArrayList of HashMap as:

SimpleAdapter listadapter = new SimpleAdapter(this, menuItems, R.layout.row, new String[] {"textone", "texttwo", "txtthree"}, new int[] {R.id.textone, R.id.texttwo, R.id.texttwo});

but for implementing SimpleAdapter you must create a layout for row with Views you want in single row

for more help you can see following tutorials to fill ListView with ArrayList of hashMap:

http://shenhengbin.wordpress.com/2012/03/17/listview-simpleadapter/

http://shenhengbin.wordpress.com/2012/03/17/listview-simpleadapter/

Professional Hosting fro Just Host

Filed under: Android Coding FAQ

Tags:

Comments

No Comments

Leave a reply