拦截行动SimpleCursorAdapter [英] Intercepting SimpleCursorAdapter Action

查看:124
本文介绍了拦截行动SimpleCursorAdapter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写其使用SimpleCursorAdapter显示来自我的SQLite数据库的项目的列表的应用程序。该应用程序是一个列表应用程序,其允许用户创建的项目的列表。有一个在数据库中保存的用户是否希望该列表项的文字划掉与否。轨道领域

基本上,我想拦截的时间,其中SimpleCursorAdapter尝试的setText()在我的crossed_out场点,而是调用一个函数来设置另一个字​​段的文本删除线。

这是可能没有写我自己的CursorAdapter?我如果不是如何去写我自己的CursorAdapter?


解决方案

  

这是可能没有写我自己的CursorAdapter?


您可以 ViewBinder 使用<一个附加一href=\"http://developer.android.com/reference/android/widget/SimpleCursorAdapter.html#setViewBinder%28android.widget.SimpleCursorAdapter.ViewBinder%29\"相对=nofollow> setViewBinder() ,并实施 ViewBinder 来格式化你的 TextViews 如你所愿。


  

如果不是我可以去写我自己的CursorAdapter?


第1步:创建 SimpleCursorAdapter

的子类

第二步:覆盖<一个href=\"http://developer.android.com/reference/android/widget/SimpleCursorAdapter.html#setViewText%28android.widget.TextView,%20java.lang.String%29\"相对=nofollow> setViewText() 并在这一点适用您的格式,或覆盖 bindView()并在所有行填充部件自己

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?

解决方案

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

这篇关于拦截行动SimpleCursorAdapter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆