SQLite query run on UI thread with ExpandableListView/SimpleCursorTreeAdapter

笑着哭i 提交于 2019-12-04 14:55:36

If they fixed it in the 2.3 SimpleCursorTreeAdapter, why don't you just download the java file and include it in your project and use that version rather than the one on the phone?

I haven't looked at the code, but as long as they didn't make any new 2.3 API calls, it should work.

Thanks for your feedback, mp2526! I apologize for my late response!

That is a great suggestion! However, I really thought that it should be possible to do this (retrieve the children cursors asynchronouosly) in API 8, and that I had misunderstood anything ... Apparently, it isn't possible (at least not with the use of SimpleCursorTreeAdapter)!

Anyway, I made a diff between API 8 and API 9 for SimpleCursorTreeAdapter, and what they have done in Android 2.3 is that the childFrom and groupFrom column ids are now initialized lazily, i.e. no longer in the constructor. Instead, these members are now initialized in the first call to bindView(). That way, there's now time to asynchronously retrieve the children cursors. As there doesn't seem to be any changes to the public API of this class between API 4 and API 9 (except the new method setViewText()), your solution to use the API version 9 of this class should work without changes! I tried it out, and it did!

Thanks a lot, mp2526!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!