Search code examples
androidlistadapter

Do ListAdapters need to be released, or is that handled automatically?


When a user selects an item in a ListView, I display a new list based on their selection using a new ListAdapter in the same activity. Do I need to release the previous ListAdapter, or will the ListView handle that automatically?

I'm allocating ListAdapters like this:

            ListAdapter adapter=new SimpleCursorAdapter(this,
                R.layout.row, tempCursor,
                new String[] {"name"},
                new int[] {R.id.name});

        setListAdapter(adapter);

Solution

  • ListView will take care of releasing the previous adapter automagically. You do not need to worry about it.