I have a footer view in the list view which contain a button “Search” ,When i click on the button “Search” i want to remove the previous data and show the new one. I am fetching the the data from the web service and showing the list using Async Task.
Currently i am unable to remove the previous data ,when i click on “Search” the data added in the same list and it shows the old and new both data.
How can i refresh the list-view. Any kind of help will be greatly appreciated.
This is my code :
MySimpleAdapter adapter = new MySimpleAdapter(HSLoc_tabActivity.this, data , R.layout.list_main,
new String[] { "name", "distance" ,"address"},
new int[] { R.id.item_title, R.id.item_subtitle ,R.id.item_subtitle1 });
//modeList.setAdapter(adapter);
//adapter.clear();
adapter.notifyDataSetChanged();
listView.setAdapter(adapter);
listView.invalidate();
Thanks !!
Clear your ‘data’ (String[] 0r ArrayList[])first in search button’s click() and then add new information into data (String[] 0r ArrayList[]) then call adapter’s notifyDataSetChanged().
just for example: