How to use CursorWrapper to filter Cursor rows

允我心安 提交于 2020-01-29 09:40:40

问题


I want to filter out some rows returned by a Cursor based on a specific condition (which I want to test after receiving the rows from the database, because it's not easy to add it to a WHERE clause in the SQL query). I found the following related questions: Filter rows from Cursor so they don't show up in ListView, Filtering a cursor the right way?, and How to hide specific rows of a Cursor in android. I want to implement exactly what those questions are asking.

While the answers to those questions show how to implement a CursorWrapper (which I have done), I don't know how to then link that CursorWrapper to the Cursor & CursorAdapter. The answers just say "Then, use your CursorWrapper in the SimpleCursorAdapter" - can someone elaborate on what this means? Specifically, where do you instantiate the CursorWrapper class and how do you use it in conjunction with the CursorAdapter?

Thanks.


回答1:


CursorWrapper implements the Cursor interface, so you can pass your CursorWrapper to your CursorAdapter in place of your Cursor.



来源:https://stackoverflow.com/questions/17333490/how-to-use-cursorwrapper-to-filter-cursor-rows

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