On Sun, Oct 31, 2010 at 5:12 AM, Peter Webb <[email protected]> wrote:
> Its perfect, except it uses SimpleCursorAdaptor, which means the list
> only binds to and displays one item per row. I want it to display two
> items, both bound the Provider. Or more accurately display the text
> from one Content Provider field and an icon which depends on the value
> of a different field.

I think SimpleCursorAdapter can handle that without subclassing via
setViewBinder(), though I haven't experimented with this yet.

> * Hand populating the ListView by reading in the Provider data and
> populating an array in OnCreate. This works, except as the data is not
> bound the List does not update when I add an item.

It also chews up lots of RAM and CPU time.

> * Extending SimpleCursorAdapter with a custom getViewBinder. Could
> still only bind to a single column.

I think you're supposed to call setViewBinder(), not override getViewBinder().

> Could someone give me at least a hint as to how I can create a custom
> CursorAdaptor which binds to two fields instead of just one like
> SimpleCursorAdapter? There must be some easy way ????

Override bindView() and bind it yourself, if needed. bindView() will
receive a Cursor (pointing at the right position in your data set) and
the View to bind it to. You can call super.bindView() to allow
SimpleCursorAdapter to do the basics, then use findViewById() on the
row View to find your ImageView and set an appropriate resource on it.

Here is a free excerpt from one of my books that touches on some of
this, though in the context of an ArrayAdapter, since by this point in
the book I haven't introduced Cursors yet:

http://commonsware.com/Android/excerpt.pdf

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android 2.2 Programming Books: http://commonsware.com/books

-- 
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