Intercepting SimpleCursorAdapter Action

僤鯓⒐⒋嵵緔 提交于 2019-12-10 23:35:14

问题


I am writing an application which is using a SimpleCursorAdapter to display a list of items from my SQLite Database. The application is a list application, which allows the user to create a list of items. There is a field in the database that keeps track of whether the user wants the list item's text crossed out or not.

Basically, I want to intercept the point in time where the SimpleCursorAdapter tries to settext() on my crossed_out field, and instead call a function to set the text of another field to strikethrough.

Is this possible without writing my own CursorAdapter? If not how can I go about writing my own CursorAdapter?


回答1:


Is this possible without writing my own CursorAdapter?

You can attach a ViewBinder using setViewBinder(), and implement a ViewBinder to format your TextViews as you wish.

If not how can I go about writing my own CursorAdapter?

Step #1: Create a subclass of SimpleCursorAdapter

Step #2: Override setViewText() and apply your formatting at that point, or override bindView() and fill in all of the row widgets yourself



来源:https://stackoverflow.com/questions/5465702/intercepting-simplecursoradapter-action

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