【问题标题】:SimpleCursorAdapter and CursorAdapterSimpleCursorAdapter 和 CursorAdapter
【发布时间】:2011-12-05 08:27:33
【问题描述】:

我想知道CursorAdapter 和SimpleCursorAdapter 有什么区别。基于什么标准有人会选择一个或另一个。你与他们合作的经历? 谢谢

【问题讨论】:

  • CursorAdapter 是抽象的。使用它完全取决于您选择如何实现它。

标签: android simplecursoradapter android-cursor


【解决方案1】:

我认为主要问题仍未得到解答。 SimpleCursorAdapter 是为那些想要节省一些时间制作自己的 CursorAdapter 的人而存在的。 SimpleCursorAdapter 已经由 google 制作,您只需告诉他布局应该如何以及您希望用您的数据块填充的小部件的 id,因此您不必覆盖 CursorAdapter 的方法并实现它们。但是你只能在布局中使用 TextView 和 ImageView,因为它目前还不支持更多的小部件。

因此,SimpleCursorAdapter 需要 2 行代码,但扩展 CursorAdapter 意味着更多,但您有更多自定义选项。我相信 SimpleCursorAdapter 在大多数情况下应该足够了。

【讨论】:

    【解决方案2】:

    CursorAdapter 是抽象的,需要扩展。另一方面,SimpleCursorAdapter 不是抽象的。

    注意 newView(Context context, Cursor cursor, ViewGroup parent) 在 CursorAdapter 中是抽象的,但在 SimpleCursorAdapter 中实现。这是因为 SimpleCursorAdapter 有一个特定的机制来启动视图,而 CursorAdapter 则由开发人员决定。

    【讨论】:

    • 好的,谢谢,但是您会选择哪一个来填充 ListView?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多