Listview with CursorAdapter

前端 未结 2 1520
天命终不由人
天命终不由人 2020-12-28 10:13

I\'m developing an application which displays Phone contacts with CursorAdapter. When I run it, I faced with a list view which repeated just one contact as bellow (\"david\

2条回答
  •  再見小時候
    2020-12-28 11:11

    Also, I suggest you switch from using CursorManager to using CursorLoader. This is documented in the Android API guide, under Loaders. A specific example that you might find useful is here.

    A Cursor Adapter "connects" a Cursor to a ListView. The Cursor is a data view of the data, and the ListView is a UI view of the same data. You don't need to program anything to make the ListView stay in sync with the Cursor, that's all handled automatically.

    You do need to tell the ListView which columns in the Cursor it should display, See the documentation for the SimpleCursorAdapter class. I usually use that class unless I have to modify the data as I move it from the Cursor to the ListView.

提交回复
热议问题