CursorTreeAdapter - 返回 Childview 数据的 Groupcursor 的一部分
我目前正在使用 CursorTreeAdapter 将 Curser 映射到 Android 中的 ExpandableListView。
除了 ListView 内部处理数据的方式之外,一切都工作正常。一般来说,所有数据都已经在 Cursor 中,我给了 CursorTreeAdater 的构造函数 - 甚至是 Childview 的 daa。问题是 Android 期望 getChildrenCursor 函数接收 ChildView 的数据:
@Override
protected Cursor getChildrenCursor(Cursor groupCursor) {
db.open();
return db.getEpisode(groupCursor.getString(0));
}
在这里您已经看到了问题。我必须返回一个光标,但我无法仅“剪切”光标中负责特定 Childview 的一个条目。相反,我想出了类似查询数据库以查找每个 ChildView 的方法。这不仅很愚蠢,因为数据已经存在(在组光标内),而且速度也相当慢。
我的问题是,是否存在某种仅克隆游标的特定条目或仅返回一个条目而不是不断查询数据库的功能。
也许我也不再使用 CursorTreeAdapter 并使用更通用的 AdapterClass 会有所帮助。
谢谢大家, 约翰内斯
I'm currently using a CursorTreeAdapter to map a Curser to an ExpandableListView in Android.
Everything works fine except from the way data is handled inside the ListView. Generally all the data is already inside the Cursor I give the Constructor of the CursorTreeAdater - even the daa for the Childview. The Problem is Android expects the data for the ChildView to be received by the getChildrenCursor function:
@Override
protected Cursor getChildrenCursor(Cursor groupCursor) {
db.open();
return db.getEpisode(groupCursor.getString(0));
}
Here you already see the Problem. I have to return a cursor but I'm not able to just "Cut out" the one entry in the Cursor that is responsible for the specific Childview. Instead I came up with something like querying the database for every single ChildView there is. This is not only dumb since the data is already there (inside the groupcursor) but it also ist pretty slow.
My Question would be if there is some kind of functionality of cloning only specific entries of cursors or returning only one entry instead of constantly querying the database.
Maybe I'm also off by using the CursorTreeAdapter and using a more general AdapterClass would be beneficial.
Thank you all,
Johannes
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我目前认为这是我们自己的。
答案是从 CursorTreeAdapter 切换到 BaseExpandableListAdapter
我之前不知何故感到害怕(不知道为什么),但现在它的工作就像一个魅力。
如果有人对代码感兴趣,我可以将其发布在这里。只需发表评论
I currently figured it our myself.
The answer was to switch from a CursorTreeAdapter to a BaseExpandableListAdapter
I somehow was scared before (dunno why) but now its working like a charm.
If someone is interested in the code I can post it here. Just leave a comment
根据要求我当前的源代码。它可能需要一些清理 - 但我希望你明白这一点。如果您还有其他问题,请询问。
As requested my current sourcecode. It may need some cleenup - but i hope you get the point. Please ask if you have additional questions.