Answer the question
In order to leave comments, you need to log in
Do I understand Adapter, notifyDataSetChanged and the purpose of the ViewHolder pattern correctly?
Given: some ArrayList with several objects of the same type, and an Adapter inherited from ArrayAdapter that will present these objects in the ListView.
Required: to update a specific object, and accordingly update the corresponding View in the ArrayAdapter.
I did it like this:
arrayList.get(...).setMyProperty(...);
adapter.NotifyDataSetChanged();
@Override
public int getCount() {
return values.size();
}
getView()
for all elements. ViewHolder
that allows in this case to get rid of inflate() and findViewById() each time each element is updated, thereby, although not abandoning getView for all elements, but optimizing it. Answer the question
In order to leave comments, you need to log in
Of course better. But in the foliage there is no way to do this without crutches. Yes, you don’t need to use leaves, take RecyclerView right away. There is a set of methods exactly what you want. And just forget the leaves.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question