My activity contains a ListView. When I open a dialog (a custom dialog that enherits from Dialog), getView() of the adapter gets called systematically, so there must be a notifyDataSetChanged called somewhere. I dont want my list to be refreshed everytime I close the dialog. How can I prevent this?
preguntado el 03 de mayo de 12 a las 14:05
It sounds like a lifecycle issue to me... like when you start a new activity from your list activity, and then go back to your list activity... If your list creation code is in onResume, it will be re-run.
Not saying that is truly the issue here, but without seeing your code that's the best guess I can make at it.
if you dont want to set notify data set change then you can save you data temporarily in any object and when you want to update it just save that data into your array list or string array which your are passing in you listview and then call notifydatasetchanged in this way it will update only when you want. It will be better if you will post some code so that we can exactly know what you want to do..
I had the same issue and thought there was nothing I could do about it.
I was adding an onClick to one of my Views when it was visible in the ListView. I didn't know it at the time, but this modification of the View (after getView) was causing the ListView to call getView() on my adapter when a Dialog was shown or closed. (Presumably for view measurement)
Since I couldn't re-add the onClick easily, I changed my code to add the onClick inside the getView() and didn't modify the view afterwards.
Turns out that now since I didn't modify my view at all (after the original getView() was called), the getView() doesn't get called on Dialog show or closed.
Not sure if this solves your issue also, but it may help others.