我正在编写一个应用程序,它使用 SimpleCursorAdapter 来显示 SQLite 数据库中的项目列表。该应用程序是一个列表应用程序,它允许用户创建项目列表。数据库中有一个字段用于跟踪用户是否希望列表项的文本被划掉。
基本上,我想拦截 SimpleCursorAdapter 尝试在 crossed_out 字段上 settext() 的时间点,并调用一个函数将另一个字段的文本设置为删除线。
如果不编写我自己的 CursorAdapter,这可能吗?如果不是,我该如何编写自己的 CursorAdapter?
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)
您可以使用 ViewBinder rel="nofollow">
setViewBinder()
,并实现一个ViewBinder
来根据您的意愿格式化您的TextViews
。步骤#1:创建
SimpleCursorAdapter
的子类步骤#2:覆盖
setViewText()
并在此时应用您的格式,或覆盖bindView()< /code> 并自己填写所有行小部件
You can attach a
ViewBinder
usingsetViewBinder()
, and implement aViewBinder
to format yourTextViews
as you wish.Step #1: Create a subclass of
SimpleCursorAdapter
Step #2: Override
setViewText()
and apply your formatting at that point, or overridebindView()
and fill in all of the row widgets yourself