Pedro Fraga
Pedro Fraga

Reputation: 119

Set text color in a single row listview android

final View rootView = inflater.inflate(R.layout.fragment_main, container, false); String[] values = { "A", "B", "C", "D", "E"}; ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, values); ListView lv = (ListView)rootView.findViewById(R.id.listView1); lv.setAdapter(adapter);

my question is how to change a single row item text color. I've seen that making a new ArrayAdapter may get that, but not uunderstanding how.

Upvotes: 0

Views: 516

Answers (1)

CodeWarrior
CodeWarrior

Reputation: 5176

You must create a CustomAdapter to handle this instead of using the ArrayAdapter. Extend the ArrayAdapter/BaseAdapter and override the getView() method and inside the getView() method according to your condition you can change the color of the text on your textView.setTextColor of your required TextView.

You can see how to implement this in this tutorial

Upvotes: 2

Related Questions