Try to implement your own ArrayAdapter
and override the getView()
method:
public class MyAdapter extends ArrayAdapter<String> {
public MyAdapter(Context context, int p_resID, ArrayList<String> p_items) {
super(context, p_resID, p_items);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);
((TextView) v).setTextColor(Color.GREEN);
return v;
}
}
Don't forget to provide an alternative else clause to set the color to the default so you don't have problems when you're dealing with a recycled row. Then in your activity:
setListAdapter(new MyAdapter(this,R.layout.list_item,My_arr));
list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:textColor="#FF0000"
/>