Skip to content

Commit 39d3b05

Browse files
committed
Fixed setAdapter bug
adapter should be mAdapter, otherwise when adding header view, mItemCount will get the original adapter's getCount(), which doesn't count the number of headers and/or footers. Later on in layoutChildren() method it'll throw IllegalStateException, because the number of mItemCount and mAdapter.getCount() will never be equal.
1 parent b81c1c6 commit 39d3b05

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/src/main/java/com/etsy/android/grid/ExtendableListView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public void setAdapter(final ListAdapter adapter) {
265265
}
266266

267267
mDataChanged = true;
268-
mItemCount = adapter != null ? adapter.getCount() : 0;
268+
mItemCount = mAdapter != null ? mAdapter.getCount() : 0;
269269

270270
if (adapter != null) {
271271
adapter.registerDataSetObserver(mObserver);

0 commit comments

Comments
 (0)