-1

I want to update the items in the list if items has been updated, but there might be no updates at all.

So my question is: if notifyDataSetChange() method is called but no changing in the adapter, will getView() method get triggered?

Updates:

Does adapter has to be used together with ListView so the getView() can be triggered after notifyDataSetChange() is called? If I manually iterate an adapter and later on call notifyDataSetChange(). Will getView() be called?

Huigege
  • 115
  • 1
  • 12
  • Yes, you pretty much have to use an `Adapter` with a `ListView`. I'm not sure exactly what you mean by "manually iterate an adapter", but the `ListView` itself is going to call `getView()` whenever it needs a `View`, including when `notifyDataSetChanged()` is called. – Mike M. Jun 21 '16 at 05:26
  • @Mike, thanks for your comments. That is all what I want to know. – Huigege Jun 21 '16 at 05:33

2 Answers2

0

It does trigger getView(), since the view that's reflecting your data needs to get refreshed.

Notifies the attached observers that the underlying data has been changed and any View reflecting the data set should refresh itself

Also check out this post which gives a very detailed explanation.

Community
  • 1
  • 1
Charles Li
  • 1,835
  • 3
  • 24
  • 40
0

Thanks Mike M. for the comment.

In order to make getView() get triggered after notifyDataSetChange() is called, I have to use Adapter with ListView. Like Mike mentioned, ListView is going to call getView().

This link might be helpful: When getView() in ArrayAdapter is called

Community
  • 1
  • 1
Huigege
  • 115
  • 1
  • 12