how to set the simplecursoradapter to a listview i

2019-03-05 16:26发布

i have to set the simpleCursorAdapter into a listView.

how can i achieve that?

thanks.

2条回答
▲ chillily
2楼-- · 2019-03-05 17:27

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

查看更多
Melony?
3楼-- · 2019-03-05 17:33

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.

查看更多
登录 后发表回答