Wednesday, June 16, 2010

[android-developers] Re: ListView with sections from a SINGLE Cursor

Ok, then I will probably stick with my current solution... if the
title has a solid background and is relatively small it all looks
pretty OK.
The only issue is the missing line under the title and the fact that
you can click the title to select the item below it.

The problem with your solution seems to be if you scroll directly to
the center of a large list, then you'd have to scan back to the
beginning to find the correct offset.

-- Jonas


On Jun 16, 6:15 pm, Mark Murphy <mmur...@commonsware.com> wrote:
> >> Actually inserting the headers as a second viewtype requires you to
> >> scan the whole result to get an accurate count.
>
> >> The best I've come up with is returning the Header combined with the
> >> first item as a single view so as to keep the count correct, but then
> >> selection looks wrong.
>
> >> Any tips?
>
> Step #1: Run a query to get you your count of headers (SELECT
> COUNT(DISTINCT artist) FROM thatfunkymusic WHERE...)
>
> Step #2: Run your current query and pour it into your existing CursorAdapter
>
> Step #3: Create a custom Adapter that wraps around your existing
> CursorAdapter (see CWAC-Adapter). This adapter will need to return the
> correct count, adjust all references to positions to take the headers
> into account, return the proper number of view types, return the
> headers for the proper positions, and all that jazz.
>
> http://github.com/commonsguy/cwac-adapter
>
> In other words, it is doable without a bunch of individual queries,
> but it is not terribly straight-forward. I have added this to my
> running list of "reusable components to write someday", but if
> somebody beats me to it, that'd be absolutely delightful.
>
> --
> Mark Murphy
> CommonsWare
> mmur...@commonsware.comhttp://commonsware.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment