I was unable to get notifyDataSetChanged () to work with updating my SimpleAdapter, so instead I first tried to remove all the views that were attached to the parent layout using removeAllViews () and then add ListView and it worked, which allowed me to update the custom interface:
LinearLayout results = (LinearLayout)findViewById(R.id.results); ListView lv = new ListView(this); ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>(); SimpleAdapter adapter = new SimpleAdapter( this, list, R.layout.directory_row, new String[] { "name", "dept" }, new int[] { R.id.name, R.id.dept } ); for (...) { HashMap<String, String> map = new HashMap<String, String>(); map.put("name", name); map.put("dept", dept); list.add(map); } lv.setAdapter(adapter); results.removeAllViews(); results.addView(lv);
Chasden Aug 22 '13 at 14:52 2013-08-22 14:52
source share