I'm using my own BaseAdapter (standingsListAdapter)
for the ListView (standingsLV)
.
When I set the Adapter:
standingsLV.setAdapter(standingsListAdapter);
getViewTypeCount()
is called.
But later, when I set new data in adapter:
standingsListAdapter.setData(data);
where setData(data)
after setting new data calls notifyDataSetChanged()
:
public void setData(StandingsModelWrapper data) {
groupsData.clear();
if (data != null) {
groupsData.addAll(data.getModel());
}
notifyDataSetChanged();
}
the method getViewTypeCount() isn't called again. Why? How to force adapter to check again getViewTypeCount()?
Why do I need this?
That is why the number of my viewtypes should be recalculated every time new data comes to the list adapter.
I don't think this is possible.
Get getViewTypeCount()
implementation is part of the definition of your adapter; it defines, regardless of what the actual data of the adapter is at any given moment, all the possible types of data it can hold.
getViewTypeCount
is called by the framework to properly recycle list-item views that could be very different between different types of the data held by the adapter. When you change data in the adapter, views are still recycled according to the existing definition/implementation of the getViewTypeCount
.
If you want a getViewTypeCount
to be called again, create a brand new adapter and set this new one as your listview's adapter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With