Search code examples
androidandroid-listviewandroid-arrayadapter

How to highlight an item of a listview programmatically?


I have a listview and I need to highlight a item programmatically.

I tried with this:

CalendarList = (ListView) findViewById(R.id.CalendarList);
CalendarList.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, MyApplication.roundMatches(CalendarPicker.getValue())));

CalendarList.setSelection(2);

but setSelection didn't work.


Solution

  • finally none of these solutions works, i did this by a different way, changing the colour of the text of the selected item