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\
I noticed a few points:
cursor.moveToNext()
.getView()
calls newView()
and bindView()
on it's own; you shouldn't call these methods yourself.findViewById()
repeatedly.getColumnIndex()
repeatedly.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.