Android: clear list in Listadapter

Possible duplicate:
how to clear the list in android

In android, I used a list, a simple adapter, and passed an array, and I want to clear the contents of the list. Instead of clearing, this is adding entries to my list.

+5
source share
3 answers

Grab my custom adapter from here. Testadapter

Now add a method like this.

public void clearAdapter()
    {
        deviceNames.clear();
        selected.clear();
        notifyDataSetChanged();
    }

Now call youListAdapter.clearAdapter()out your activity.

+12
source

Just write listView.setAdapter (null)

+12
source

notifydataSetInValidated() , , . null: l.setAdapter(null);

0
source

All Articles