ExpandableListViews, SimpleCursorTreeAdapter and my sanity

Put your problem here if it does not fit any of the other categories.

ExpandableListViews, SimpleCursorTreeAdapter and my sanity

Postby LacunaZA » Fri Feb 11, 2011 9:07 am

Hi everyone

I've been stuck on this issue for a couple of days now and I think I'm close to murder, so any help would be greatly appreciated.

First just a little context.

I have a db with a Budget and Category tables. The fields are _id ,CategoryID, Item and Amount. The amount is stored as a double. I've written my own db adapters and they are working no problem. So with lots of reading and searching I finally get my ExpandablListView to populate using my slightly modified SimpleCursorTreeAdapter. My custom adapter just changes the GetChildrenCursor to return the children associated with each category.

Now here's the problem:

The amount value is shown in the list and I would like to format how the value is displayed into a local currecy. The formatting isn't the issue. The issue is that I can use a ViewBinder but only if I use API level 5 and up. But I want to use API level 4 and up.

So how do I change the way the data is displayed in my list items, without having to use a viewbinder... or at least, working withing the API 4 framework.

ANY advice or ideas would be appreciated!

Kind regards
LacunaZA
Freshman
Freshman
 
Posts: 8
Joined: Fri Feb 11, 2011 8:57 am

Top

Re: ExpandableListViews, SimpleCursorTreeAdapter and my sani

Postby LacunaZA » Tue Feb 15, 2011 9:17 am

Thanks to some help from I finally managed to sort this one out.

The trick for API 4 and below is to override the bindChildView and bindGroupView and do your magic there. When you've finished doing your bit, you call the super method of the same name so that the simplecursoradapter can manage the rest of the binding. The only trick is to not pass the value and item id to your adapter cause you'll bind that manually and not through the adapter.

I'll try and write a proper tutorial on it soon and post the link to it here if anyone ever needs it.
LacunaZA
Freshman
Freshman
 
Posts: 8
Joined: Fri Feb 11, 2011 8:57 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 12 guests