I'm trying to implement the above mentioned. From this link, http://www.pocketmagic.net/开发者_开发知识库?p=1870 , it pretty much shows what I'm trying to achieve, except I want to show an icon on the left side of the contact based on a condition. i.e. If Aaron is in Company A show Company A icon, if Betty is in Company B show Company B icon. Problem is the contacts data is from 1 cursor and the company data is from another cursor.
I'm looking at a custom cursor adapter, is there a way to create a single cursor with data from 2 cursors and set it into the list adapter? How this makes sense. Thanks!
This can only be done if you extend the cursor adapter and then INTERCEPT the data when its building the views and build it how you want it with the cursor data that will be coming in. Once you have this setup its pretty easy. And there is a cursor that can take two cursors and put them together.. but I can't remember if this was custom or not.
Simple way is to just take the data and throw it into a datastructure and then handle it from there. Also there is no rule saying you can't pass in two cursor into your cursor adapter. MAKE IT YOURS! :)
I just answered a similar question to this that was to use an ArrayAdapter of an Object list. Take a look at the code I posted and instead of extending ArrayAdapter, extend CursorAdapter (If you need to use a Cursor). Or you can build up a Custom Object and use the ArrayAdapter approach
How to put query of information into a listview?
Also, here's the reference for a CursorAdapter:
http://developer.android.com/reference/android/widget/CursorAdapter.html
Hope this helps!
精彩评论