You can use setChoiceMode
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
call this method before calling set adapter. And override the getview
method of your adapter.
Sample code.
public View getView(int position, View convertView,
ViewGroup parent) {
if(convertView!=null){
ImageView img = (ImageView)convertView.findViewById(R.id.imageView1);
if(mylist.isItemChecked(position)){
convertView.setBackgroundColor(Color.WHITE);// here you can set any color.
img.setImageResource(R.drawable.img1);//img1 is stored in your rawable folder.
}else{
convertView.setBackgroundColor(0);
img.setImageResource(R.drawable.img2);
}
}
return super.getView(position, convertView, parent);
}
I hope this will give you the solution what you want. All the best. Thank you.