For anyone looking to dynamically add a header to a sorted cursor in a list,
Kostya's suggestion worked brilliantly. In getView override check the column
value you're sorting on of the previous cursor position to determine if you
need to use a regular row or a view which contains both a header *and* a row
layout.


On Fri, Jul 30, 2010 at 3:02 PM, Connick <oconn...@gmail.com> wrote:

> I'm with you on that ...re: header part of hierarchy, that's the direction
> I'm going but I was worried about position mapping ...you're suggestion to
> include the header view with a row item would solve that problem!
> Gracias, will give that a shot.
>
> Cheers
> S
>
>
> On Fri, Jul 30, 2010 at 2:53 PM, Kostya Vasilyev <kmans...@gmail.com>wrote:
>
>>  It does on my phone - Samsung Galaxy S with Android 2.1update1. This is
>> the built-in Android email client, set up with an IMAP account.
>>
>> I just had an idea.
>>
>> It should be much easier to implement the header as part of data item view
>> hierarchy. This way the number of items in the list view is exactly the same
>> as the number of items in the cursor, and you can avoid extra code dealing
>> with counting data items and mapping their positions.
>>
>> You'd have two kinds of list item views - one with the header, one
>> without. Deciding which one to use is pretty simple - in the adapter's
>> getView, compare the item's data with the previous item's. If they differ,
>> you need to use the version with the header.
>>
>> -- Kostya
>>
>>

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to