Skip to content Skip to sidebar Skip to footer

How To Set The Simplecursoradapter To A Listview In Android?

i have to set the simpleCursorAdapter into a listView. how can i achieve that? thanks.

Solution 1:

This question is a bit vague, so I'm tempted to answer simply:

my_list_view.setAdapter(my_cursor_adapter);

But there are better explanations and examples in the documentation. Here is one:

http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List2.html

Solution 2:

ListView has the method declard as:

publicvoidsetAdapter(ListAdapter adapter)

And the documentation for ListAdapter lists SimpleCursorAdapter as one of its own indirect subclasses. So to set your SimpleCurseAdapter into a ListView, you just need call setAdapter on the view with your adapter.

Post a Comment for "How To Set The Simplecursoradapter To A Listview In Android?"