I’m a bit of a first-timer to Android, but as far as I know, if I want to bind my database to a list view with a custom row, I’ll need to override the CursorAdapter. However, I can’t start working on it because of a feature I wish to implement on my list view: not only do I want to present my list view arranged according to the ascending value of dates, I also want to have two separate sections in my list view that are both sorted according to dates but using the same cursor (if that’s even possible).
A simplified version of my schema could go like this:
_ID, NAME, DATE, TRUTH_VALUE
My default view is to have the resulting cursor’s rows sorted by date, but I also want to “filter” or make sections out of the cursor that are separated according to the “TRUTH_VALUE”, meaning I could have section 1 in my list contain items with an arbitrary value of 0 in “TRUTH_VALUE” that are sorted according to date, and have section 2 contain items whose TRUTH_VALUE columns are an arbitrary 1 that are sorted according to date as well.
I can’t seem to find any sort of adapter, or whatever, that could either accept two cursors (that are then made into a single filtered ListView) nor am I considering putting some extra parameters in my custom adapter’s constructor (eg, in instantiating my adapter, I include a value in the parameter that helps the adapter determine whether it can just modify the way it binds a cursor’s data, which I think is impossible, or just plain difficult; not to mention lead to performance problems).
Thanks in advance!
What if your SQL query was:
This should order the items in the way you want. Then in your CursorAdapter you could check the value of truth_value, and when it changes, do something different. Although I’m not sure exactly what it is you are trying to achieve with the layout.