如何使光标适应具有大量自定义行为的 ListView?

发布于 2024-11-05 12:04:00 字数 523 浏览 1 评论 0原文

我目前正在开发一个 Android 应用程序,该应用程序使用 SimpleCursorAdapter 和自定义 ViewBinder 来设置 ListView

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

我完全支持优化,但是我需要项目在 ListView 中正确显示。正确的做法是什么?

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

I'm currently working on an android application that uses a SimpleCursorAdapter with a custom ViewBinder to set specific text color and image visibility on items in my ListView.

However, when my list is longer then the size of a screen, and the user scrolls up and down, the system causes incorrect rows to take on the wrong coloring, etc. My understanding is that this is an issue of the system re-using views as an optimization in scrolling, as explained here.

I'm all for optimization, however I need items to display properly in the ListView. What is the correct way to go about this?

My thinking is that I could implement a CursorAdapter, or preferably a SimpleCursorAdapter, but I don't know how to go about doing so. Alternatively, is it just a matter of setting text color back to its default in my ViewBinder?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

述情 2024-11-12 12:04:00

是的,这是在 getView() 中将每一行设置为正确的颜色/值等的问题。至于 simpleCursorAdapter - 我找到了一个很好又简单的教程: http:// /thinkandroid.wordpress.com/2010/01/09/simplecursoradapters-and-listviews/

Yes, it is a matter of setting every row to a proper color/ values etc. in getView(). As to the simpleCursorAdapter - I found a nice and simple tutorial: http://thinkandroid.wordpress.com/2010/01/09/simplecursoradapters-and-listviews/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文