When I have this in a similar example, I have a global field with the name:
selectedListItem;
This will be updated in your onitemClickListener, and the previous item will then return it to its default value.
So, to update the code:
private class ListViewItemClickListener implements AdapterView.OnItemClickListener { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
It's so easy to initalise selectedListItem as a field in your adapter with onClickListener as an inner class, and instead of list_default_background you can use the default background image.
Alternatively, you can track item numbers instead of the actual presentation.
EDIT:
To use this method for your list, you will also need to track an instance of an identifier or object for your specific list item. In my own solution, in my getView ListAdapter method, I make sure that only the list item that matches the identifier / instance of the correct item is updated. With your code, like you, you will also find that when you scroll down, the view at the same position in this list of visible elements is also updated. This is due to the fact that viewing a list refers to a list in sets of elements, where each set corresponds to elements visible on the screen at any given time.
To update a particular, specific element, it is better for you to use the background of a selector or indicator, as indicated in other answers.
NTN
source share