I have a ListView, which is backed by an ArrayAdapter. They are defined as such:
ListView listView = (ListView)findViewById(R.id.listview);
ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(this, R.layout.list_item);
listView.setAdapter(listAdapter);
list_item.xml contains the following:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:textSize="16sp">
</TextView>
What I would like to do when adding an item to the list, is edit the TextView associated with the item, like changing it’s colour for example. How would I go about doing this?
You could override the method
getView()of your ArrayAdapter (link to the reference) for example: