Richard,

Adapter view binders are only a convenience feature, and you can always skip to the real stuff.

SimpleCursorTreeAdapter has this private method where mViewBinder is used:

private void bindView(View view, Context context, Cursor cursor, int[] from, int[] to) {
ViewBinder binder = mViewBinder;
for (int i = 0; i < to.length; i++) {
if (binder != null) {
bound = binder.setViewValue(v, cursor, from[i]);
}
... default case for when there is no binder ...
}
}

This method is called from public, API level 1, override-able SDK methods:

@Override
protected void bindChildView(View view, Context context, Cursor cursor, boolean isLastChild) {
bindView(view, context, cursor, mChildFrom, mChildTo);
}

@Override
protected void bindGroupView(View view, Context context, Cursor cursor, boolean isExpanded) {
bindView(view, context, cursor, mGroupFrom, mGroupTo);
}

So - override bindChildView / bindGroupView to format and set the values any way you like. You can even make your own MyBinder class and follow the general structure as above.

Also, if you're not using automatic view binding, your might as well derive your adapter from ResourceCursorTreeAdapter.

In general, my impression of Simple*Adapter classes is that they are like bicycles for small children (those with little wheels on the sides) - not a bad way to start, but you outgrow them pretty quickly.

-- Kostya

11.02.2011 11:41, Richard Marsh пишет:
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 currency. 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 --
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

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

Reply via email to