What's the role of adapters in Android?

前端 未结 10 1218
面向向阳花
面向向阳花 2020-12-02 04:10

I want to know when, where and how adapters are used in the context of Android.

The information from Android\'s developer documentation wa

10条回答
  •  情话喂你
    2020-12-02 04:40

    Adapters in Android are a bridge between the adapter view (e.g. ListView) and the underlying data for that view. Imagine what the world would have been without adapters!

    Examples

    • A view that shows items in a vertically scrolling list. The items come from the ListAdapter associated with this view.

    • The ListAdapter defines the layout for individual rows of the list and provides data to the ListView via the setAdapter() method of ListView.

    • Android provides several standard adapters; the most important are ArrayAdapter and CursorAdapter.

    • ArrayAdapter can handle data based on arrays or lists.

    • SimpleCursorAdapter can handle database related data.

提交回复
热议问题