Question

I need all of the other views in my arrayadapter to check their attributes and return to a default attribute at certain times

use case: listview items (a)(b)(c)(d) , when you touch (a) it's background turns black. This is done in the ontouchListener. But when you touch view (b) it's background turns black BUT (a)'s needs to turn back to the default which is not black

I dabbled around with recalling the arrayadapter at the end of the view.OnClickListener but the problem with this is that it also resets the scroll position of the view, so if this list was much longer - which it is - and user touched item (r) , then it would reset the list and put the user back at item (a) at the top

I was looking at notifydatasetchangedbut I am not sure how to use that and where it should work

insight appreciated

Was it helpful?

Solution

notifyDataSetChanged will do the job. You can call that at any time in your code and this will trigger the adapter to call getView for the visible list items again and so update their content. So basically the only thing you have to do is to update the list item states or information before calling that method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top