how to set the simplecursoradapter to a listview in android?

我的未来我决定 提交于 2020-01-30 12:02:30

问题


i have to set the simpleCursorAdapter into a listView.

how can i achieve that?

thanks.


回答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




回答2:


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.



来源:https://stackoverflow.com/questions/2264986/how-to-set-the-simplecursoradapter-to-a-listview-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!