My question is based on this post.
Android. How does notifyDataSetChanged() method and ListViews work?
I've read in various articles that to refresh the listView you must call notifyDataSetChanged()
and not listView.setAdapter(new Adapter(....));
because the second method is too costly and affects performance
The answer to the above question says that adapter.notifyDataSetChanged()
affects the views that are currently visible on the screen. So getView()
is called as many times as the number of items currently displayed.
But getView()
is called the same number of times when assigning a new adapter to the listView as well.
So what is the difference between calling adapter.notifyDataSetChanged()
and listView.setAdapter(new Adapter(....));
?