Android - CursorAdapter-ish 子类,用于 ListView
我目前在我的应用程序中使用了一堆具有自定义布局的子类 CursorAdapter,用 SQLite 查询返回的 Cursor 填充它们,然后允许它们填充我的 ListView,在设置它们之后,
setListAdapter(new SearchAdapter(this, searchCursor));
无论如何我可以获得相同的行为,但不是传入一个 Cursor 传入一个
ArrayList<String[]>
是否会有不同的类来进行子类化? (显然)或者,我应该以某种方式将 ArrayList 转换为 Cursor 吗?或者,我缺少其他方法吗?
谢谢!
I currently use a bunch of subclassed CursorAdapters with custom layouts throughout my app, populating them with a Cursor returned by an SQLite query, then allowing them to populate my ListView, after setting them with
setListAdapter(new SearchAdapter(this, searchCursor));
Is there anyway I can get the same behavior but instead of passing in a Cursor pass in an
ArrayList<String[]>
Would there be a different class to subclass? (Obviously) Or, should I convert the ArrayList to a Cursor somehow? Or, is there a different method I am missing?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用数组适配器(也可以子类化基本适配器)来完成此操作,并实现您自己的在列表中显示对象的方式。谷歌上有很多关于如何做到这一点的教程。
只需搜索 ArrayAdapter、Base 适配器即可。 :D
希望这有帮助,
小心。
you can do it with an array Adapter (also you can subclass Base adapter) and implement your own way of displaying objects in a list. there are plenty of tutorials on google on how to do that.
Just search ArrayAdapter, Base adapter. :D
Hope this helps,
Take care.