Sunday, October 31, 2010

[android-developers] Extending SimpleCursorAdapter

I'm an Android newbie, stuck on a problem for a over week now, if I
knew what I was doing it would be 10 minutes work.

Im using the NotePad example as a base for an application. This binds
a ListActivity to a Provider.

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.

This sounds like a pretty simple thing to do, a very slight
modification to the NotePad application. Trouble is, I have no idea on
*how* to do it. I really need a starting point, and "approach" to use.

So far I have tried (unsuccessfully):

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

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

* Building my own ListAdaptor. Couldn't get this to work.

* Concatenating both fileds together and "parsing" 2 fields into 1
field read/write.

The next thing I will try is extremely tacky running two separate
simpleCursorAdaptors in two views in a Linear Layout, fudged so the
row height is identical, and duplicate the logic.

I say this only to show that I really, really have tried.

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

Sorry/thanks/help

Peter Webb

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate