i am implementing a spinner using material autocompletetextview and i want to change the background color of each item . here is what i've done , but still not working :
binding.civiliteInput.setOnItemClickListener { parent, view, position, id ->
Log.d("TAG", "fillInput: the item selected is : "+parent.getItemAtPosition(position).toString())
if(parent.getItemAtPosition(position).toString() == "Mr"){
view.setBackgroundColor(ContextCompat.getColor(requireContext(),R.color.lagfo_color))
Log.d("TAG", "fillInput: the item selected is : Mr coleur lagfo")
}else if (parent.getItemAtPosition(position).toString() == "Mme"){
view.setBackgroundColor(ContextCompat.getColor(requireContext(),R.color.rose_pale))
Log.d("TAG", "fillInput: the item selected is : Mme coleur lagfo")
}else if (parent.getItemAtPosition(position).toString() == "Mlle"){
Log.d("TAG", "fillInput: the item selected is : Mlle coleur lagfo")
view.setBackgroundColor(ContextCompat.getColor(requireContext(),R.color.lagfo_color))
}
civilite=binding.civiliteInput.text.toString();
}