I want make a ListView
that have some elements with the WHITE
text color and some other elements with the BLACK
text color.
Here is my code for now:
ArrayAdapter<String> arrayAdapter =
new ArrayAdapter<String>(My_Activity.this, R.layout.row_lay, R.id.textViewList, myarray);
listLead.setAdapter(arrayAdapter);
I can modify the TextColor of my R.layout.row_lay
but this change the color for all the Line of my ListView. How can I do for example one line a color and the other another one?
Is possible to achieve that ? Different TextColor in the same ListView?
If yes how?
You're going to have override the getView
method of the ArrayAdapter
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(My_Activity.this, R.layout.row_lay, R.id.textViewList, myarray) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);
//your condition logic
v.setBackgroundColor(yourColor);
return v;
}
};