I need to refresh the ListView items every second, and it works fine using notifyDataSetChanged(). After the refresh, the already selected item in the list is losing its selection. ie, it loses its selected item background. How can I maintain the selected state of already selected item, after each refresh?
Thanking u for the support in advance.
As I understood your question your query is that you are losing the selected item focus of the ListView after refreshing the ListView. So, for that you can use
ListView's setSelection() methodto set the selected item in the ListView. So, when you refresh the ListView after that you can set the item that you want to be selected or the previous selected usingsetSelection().Here
positionis the position that was the last selected index beforenotifyDataSetChanged()