setBackgroundcolor error in the onitemclicklistener

I want items to change color when the user selects them. But when an item changes color, another item changes in the same way, I don't know why this error occurs, this is the code

override fun onItemClick(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
    var ds=listView1.adapter.getItemId(position)
    parent?.get(position)?.setBackgroundColor(Color.argb(96,189,189,189))
}

I do not know if there is any other function that I do not know, it should be noted that I am starting in Android programming, if you could help me



Read more here: https://stackoverflow.com/questions/67386064/setbackgroundcolor-error-in-the-onitemclicklistener

Content Attribution

This content was originally published by frodrig574 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: