On Thu, Jan 5, 2012 at 9:50 AM, John Davis davi...@gmail.com 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?
Override getView() of your ArrayAdapter (or bindView() of your
CursorAdapter) and put in the logic to set the
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;inumRows;i++) {
rowView =
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
Hmm.
Ok, I maybe over my head. I guess the first thing to do is subclass
array adapter as you said first so I can override its getView call.
--
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to
On Thu, Jan 5, 2012 at 10:19 AM, John Davis davi...@gmail.com wrote:
Ok, I maybe over my head. I guess the first thing to do is subclass
array adapter as you said first so I can override its getView call.
Right. Here is a free excerpt from one of my books that goes through
that process:
Hello Mark,
Ok. Thanks. I've managed to create my own MyAdapter. I'm guessing, I
need to override the getView routine there now. The code still works
using the custom adapter. It was a struggle ot get the constructor
right.
I'll look at your pdf in a bit. Let me struggle with the concept of
Well,
I have this in my main class:
// Build the listview
MyAdapterString adapter = new
MyAdapterString(this,android.R.layout.simple_list_item_1, values);
// ArrayAdapterString adapter = new
ArrayAdapterString(this,android.R.layout.simple_list_item_1,
values);
I changed the getview code so it only calls the super code once and
returns the rowView as you did.
public class MyAdapterT extends ArrayAdapterT {
public MyAdapter(Context context, int textViewResourceId, T[] objects)
{
super(context, textViewResourceId, objects);
If the TextView is truly invisible, you need to make it visible, using
setVisibility().
Otherwise, use Hierarchy View to examine your UI and see what is going on:
http://developer.android.com/guide/developing/debugging/debugging-ui.html
On Thu, Jan 5, 2012 at 10:57 AM, John Davis
This also does not work:
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View rowView;
rowView = (TextView) super.getView(position, convertView, parent);
//
In the getView code, when I returned the super call, it was blank
text. When I returned a row as you did in your example, it would show
the text in gray/white. Trying everything to change the color results
in no change. If I want to change the text color should I uses
SetBackgroundColor or
On Thu, Jan 5, 2012 at 11:07 AM, John Davis davi...@gmail.com wrote:
If I want to change the text color should I uses
SetBackgroundColor or SetTextColor?
setTextColor(). Note that you probably do not want to be using a hex
value, but rather a ColorStateList, if your color may be unreadable
when
12 matches
Mail list logo