Yes, I would think it is possible, but not in this version. Its
possible to set all line items to the same value. However, its not
possible to set the colors on a case by case value using the provided
api.
This code will set all the line items to blue:
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View row;
row = super.getView(position, convertView, parent);
TextView text;
// text = (TextView) row.findViewWithTag(2);
text = (TextView) row.findViewById(android.R.id.text1);
text.setTextColor(Color.parseColor("#64788e"));
return row;
}
I tweaked it to use the tag like so:
public View getView(int position, View convertView, ViewGroup parent) {
View row = super.getView(position, convertView, parent);
TextView text = (TextView) row.findViewWithTag(99);
// if this row has been tagged with the marker, set the color to blue
if (null != text) {
text.setTextColor(Color.parseColor("#64788e"));
}
// This will set all row items to be blue.
// text = (TextView) row.findViewById(android.R.id.text1);
return row;
}
But the api does not allow you to set a tag outside this code so that
the routine can change the text color based on the tag.
ie.
View rowView;
int listCount;
View fooView;
listCount = adapter.getCount(); // this says 6 items in array
int count = -1;
count = theList.getCount(); // this also says 6 items in teh view
for (int i=0;i<numRows;i++) {
// If it is the 2nd or 5th item, tag it so that it will be
displayed in blue.
if (i==2 || i==5) {
fooView = (View) theList.getItemAtPosition(i); // this
line
has a bug and will not work as described.
fooView.setTag(99);
}
}
public Object getItemAtPosition (int position)
Since: API Level 1
Gets the data associated with the specified position in the list.
Parameters
position Which data to get
Returns
The data associated with the specified position in the list
If you try to get this data, it raises an exception.
--
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