Android - Populating a listview using fragments and a Simple cursor adapter

a 夏天 提交于 2019-12-04 18:36:06

Your problem is when you pass the fragment layout instead of the list view item layout. From what I can see your list view item is included inside your fragment_add_server.xml layout (since you put ... before and after the xml snippet). Move the snippet into its own file, something like my_list_view_item.xml and use that when creating your SimpleCursorAdapter.

mCurAdapter = new SimpleCursorAdapter(view.getContext(),R.layout.my_list_view_item,mNotesCursor,from,to,0);

I solved the problem i had by changing the layout in the simplecursoradapter. Instead of

mCurAdapter = new SimpleCursorAdapter(view.getContext(),R.layout.fragment_add_server,mNotesCursor,from,to,0);

i did:

mCurAdapter = new SimpleCursorAdapter(view.getContext(),android.R.layout.simple_list_item_1,mNotesCursor,from,to,0);

Essentially changing the layout to the generic android list layout did the trick! :)

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