I know a list view needs an adapter, but WHY what is the purpose of it, and can it show lists without an adapter ?
2 Answers
From the docs:
An
Adapterobject acts as a bridge between anAdapterViewand the underlying data for that view. TheAdapterprovides access to the data items. TheAdapteris also responsible for making aViewfor each item in the data set.
The ListView needs to know which items to show, and needs to get Views for these items. The Android team chose to implement this using Adapters.
Note that for showing simple lists of Strings, there is the ArrayAdapter class.
- 98,571
- 55
- 246
- 278
An adapter manages the data model and adapts it to the individual rows in the list view.
Filtering and sorting of the data is handled by the adapter.
The notifyDataSetChanged() method on the adapter is called if the data has changed or if new data is available.
The notifyDataSetInvalidated() method is called if the data is not available anymore.