How can remove adapter from Listview, Android

jER.emY picture jER.emY · May 29, 2014 · Viewed 15.3k times · Source

I use SimpleAdapter with custom row layout for Listview

SimpleAdapter adapter = new SimpleAdapter(ListOrder.this, oslist,
                    R.layout.list_v, 
                    new String[] { "name","time","status" }, 
                    new int[] { R.id.tablename, R.id.timeorder, R.id.status});
            list.setAdapter(adapter);

After , i reload data of Listview and i want remove old data. I don't know how i can't remove old data before add new data to Listview.

I used

adapter.remove(adapter.getItem(i));

but have error

The method remove(Object) is undefined for the type SimpleAdapter

Please help me ! Thank you!

Answer

Ashish Mohan picture Ashish Mohan · Jun 29, 2016

You can simply set

listview.setAdapter(null);