From Avinash Kumar Pankaj's example
View v;
then at oncreate method
v = new View(getActivity());
and then onlistitemclick method i wrote
public void onListItemClick(ListView listView, View view, int position,
long id) {
v.setBackgroundResource(0);
view.setBackgroundResource(R.color.green);
v = view;
}
It worked for me. Thank you.
I replaced
v = new View(getActivity());
to
v = new View(this);
and the code worked well.
It is necessary the xml files 'colors' and 'bg_key' from previous examples too, as well as ListView attribute android:background="@drawable/bg_key"
Mauro