views:

537

answers:

2

hi all,

i have to set the simpleCursorAdapter into a listView.

how can i achieve that?

thanks.

+2  A: 

Hi,

ListView has the method declard as:

    public void setAdapter (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.

Klarth
hey thanks for reply. but my activity is not a listactivity. i want to set into tab content how to do that???
Praveen Chandrasekaran
+1  A: 

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

moraes
hey thanks for reply. but my activity is not a listactivity. i want to set into tab content how to do that???
Praveen Chandrasekaran
ListActivity is just a fancy activity with some utilities for lists. Not too much there, really. To set the adapter in other Activity types, you get the ListView using getViewById() and then call setAdapter() on it.
moraes