【问题标题】:How can I adapt a cursor to a ListView with a lot of custom behavior?如何使光标适应具有大量自定义行为的 ListView?
【发布时间】:2011-05-07 15:56:25
【问题描述】:

我目前正在开发一个 android 应用程序,该应用程序使用 SimpleCursorAdapter 和自定义 ViewBinder 来设置我的 ListView 中项目的特定文本颜色和图像可见性。

但是,当我的列表长于屏幕大小,并且用户上下滚动时,系统会导致错误的行呈现错误的颜色等。我的理解是这是系统的问题如here 所述,重用视图作为滚动优化。

我全力支持优化,但是我需要在ListView 中正确显示项目。解决这个问题的正确方法是什么?

我的想法是我可以实现CursorAdapter,或者最好是SimpleCursorAdapter,但我不知道如何去做。或者,是否只是在我的ViewBinder 中将文本颜色设置回其默认值?

【问题讨论】:

    标签: android android-listview simplecursoradapter android-viewbinder


    【解决方案1】:

    是的,在 getView() 中将每一行设置为适当的颜色/值等。至于 simpleCursorAdapter - 我找到了一个不错且简单的教程:http://thinkandroid.wordpress.com/2010/01/09/simplecursoradapters-and-listviews/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-13
      • 1970-01-01
      • 1970-01-01
      • 2014-06-18
      • 2014-09-29
      • 1970-01-01
      • 2014-10-01
      相关资源
      最近更新 更多