Your primary job is to get the color right when the row is created.
That involves what I wrote:

> Override getView() of your ArrayAdapter (or bindView() of your
> CursorAdapter) and put in the logic to set the color as part of
> configuring that row.

Now, if in addition to that, the color change needs to happen in real
time for an existing already-displayed row, then you will need to do
something reminiscent of what you have below. However, rather than
calling getView(), you need to get the *existing child* of the
ListView.

On Thu, Jan 5, 2012 at 10:08 AM, John Davis <[email protected]> wrote:
> Hello Mark,
>
> Thanks for your response.  I tried various things already.  Here is
> what kind of made sense but did not work:
>
>  // Set the color based upon the faction.
>  View rowView;
>  int listCount;
>  View fooView;
>
> listCount = adapter.getCount();
> for (int i=0;i<numRows;i++) {
>  rowView = adapter.getView(i, null, theList); // theList is the
> listview, adapter is its ArrayAdapter
>  ((TextView)rowView).setTextColor(0x64788e);
>  if (rowView != null) {
>    if (c.getString(1).equals("foo")) {
>      ((TextView)rowView).setTextColor(0x64788e);
>    }
>  }
> }
>
>
>
> On Thu, Jan 5, 2012 at 9:59 AM, Mark Murphy <[email protected]> wrote:
>> On Thu, Jan 5, 2012 at 9:50 AM, John Davis <[email protected]> wrote:
>>> I have a listview with items in it.  I would like to set certain line
>>> items to be a certain color.  Is this possible?
>>
>>
>> --
>> Mark Murphy (a Commons Guy)
>> http://commonsware.com | http://github.com/commonsguy
>> http://commonsware.com/blog | http://twitter.com/commonsguy
>>
>> Warescription: Three Android Books, Plus Updates, One Low Price!
>>
>> --
>> 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
>
>
>
> --
> John F. Davis
>
> 独树一帜
>
> --
> 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



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

Warescription: Three Android Books, Plus Updates, One Low Price!

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