how to refresh custom listview using baseadapter in android

create one custom method in BaseAdapter

like:

 public void updateAdapter(ArrayList<Contact> arrylst) {
        this.arrylst= arrylst;

        //and call notifyDataSetChanged
        notifyDataSetChanged();
    }

and this function call where u want to call: e.g

adapterObject.updateAdapter(Here pass ArrayList);

done.


Two options: either hold onto the reference for the ArrayList that you passed into the constructor so you can modify the actual list data later (since the list isn't copied, modifying the data outside the Adapter still updates the pointer the Adapter is referencing), or rewrite the Adapter to allow the list to be reset to another object.

In either case, after the ArrayList has changed, you must call notifyDataSetChanged() to update your ListView with the changes. This can be done inside or outside the adapter. So, for example:

public class MyCustomBaseAdapter extends BaseAdapter {
    //TIP: Don't make this static, that's just a bad idea
    private ArrayList<Contact> searchArrayList;

    private LayoutInflater mInflater;

    public MyCustomBaseAdapter(Context context, ArrayList<Contact> initialResults) {
        searchArrayList = initialResults;
        mInflater = LayoutInflater.from(context);
    }

    public void updateResults(ArrayList<Contact> results) {
        searchArrayList = results;
        //Triggers the list update
        notifyDataSetChanged();
    }

    /* ...The rest of your code that I failed to copy over... */
}

HTH