On Thu, Jan 5, 2012 at 11:04 AM, John Davis <[email protected]> wrote:
> Or, is there a way to patch up this code to do what I want?
>
Yes.
> It seems pretty trivial to do.
>
It is once you get the hang of it.
> I don't understand why the hooks do not exist for what i want to do.
>
They do, but your hanging the wrong things on the hooks =).
Here's the general process for binding your data to a list view.
Create a custom class that is your data model that will be represented in
your UI. It has the properties you care about displaying in the list. In
this case, the text and color.
class MyType
{
String Text;
int Color;
}
Your ListAdapter is typed using your custom class.
ArrayAdapter<MyType> adapter = new ArrayAdapter<MyType>();
Then in your getView():
MyType selection = getItem(position);
CustomViewToReturn view = convertview != null convertView :
inflateFromXML(my_view_layout);
populateViewWithSelection(selection, view); // Set text and color on the
view using your object's state
return view;
-------------------------------------------------------------------------------------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices
--
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