Search code examples
androidlistviewadapter

Choice of an adapter for a listview


I know there are several adapters to manipulate listviews like ArrayAdapter, BaseAdapter, CursorAdapter and so on, but I don't how to choose the best solution for my needs... I mean, when I'm choosing the adapter, which are the criterias that I should check before select the adapter to use?

Every kind of help will be appreciated!


Solution

  • The major concern in adapter selection is how you get your data to populate the list.

    If the data is coming from a database/cursor, you should use one of the cursor adapters. You could use an array adapter, but that would just be unnecessary computational cycles to transfer the cursor data to the array before setting the adapter.

    If your data is in an array then your obvious choice is one of the array adapter types.

    If your data is coming from different sources, you'll need to create your own adapter or modify one of the existing ones.

    After the incoming data format consideration might come thought on list modification and which adapter would work best with whatever needs you have to modify the list (and/or the data backing it).