What is an adapter in android?
bridge between source and layouts
bridge between source and adapter views
bridge between listview and view
bridge between view and activity
Adapter Design Patterns:
1. If destination is expecting one kind of input and source is giving one kind of input then we have to use adapters to convert source into destination.
2. Whenever you change the source we have to use a different kind of adapter.
adapter design pattern is used for bridging between source and adapter views.
Functionalities of Adapter:
It takes the input from source and gives to the destination.
Any view that is getting input from any adapter is called as Adapter View.
List view is an example of adapter view.
List view generally will contain vertically scrollable list of items.
NOTE: Source should not directly communicate with destination (Adapter view).
FUNCTIONALITIES OF ADAPTERS IN AANDROIDANDROIDNDROID:
1. Adapters will take inputs from source and gives to the destination.
2. If there is any change in the source and if we notify to the adapter then adapter will go and modify the destination.
3. Adapter will take each data item from source and prepare a view and dispatches that view to the destination.
Examples for adapters:
eg1 : If you want to display data from array list into listview, then we use arrayadapter in android.
eg2 : if you want to display data from database into a listview, then we use cursoradapter in android.
Back To Top