felipecsl / AsymmetricGridView

Android ListView that mimics a GridView with asymmetric items. Supports items with row span and column span
http://felipecsl.com/AsymmetricGridView
MIT License
1.84k stars 431 forks source link

Cannot use AsymmetricGridView with an adapter that contains multiple view types #30

Closed supersume closed 9 years ago

supersume commented 9 years ago

When using an adapter with multiple view types (in my case 4), the overridden method getViewTypeCount() never gets called. The adapter only uses one view type in getView (the first one to be inflated). Please provide a fix for this. Thanks.

RoRoche commented 9 years ago

Did you try to override the AsymmetricGridViewAdapter class? So that you can provide your expected values such as:

@Override
public int getViewTypeCount() {
    return wrappedAdapter.getViewTypeCount();
}

@Override
public int getItemViewType(int position) {
    return wrappedAdapter.getItemViewType(position);
}
supersume commented 9 years ago

Yes I have done that. The result is that multiple view types now appear, but their assignment is random. They don't follow any rules that I set in my adapter class. On May 27, 2015 4:09 PM, "RoRoche" notifications@github.com wrote:

Did you try to override the AsymmetricGridViewAdapter class? So that you can provide your expected values such as:

@Override public int getViewTypeCount() { return wrappedAdapter.getViewTypeCount(); }

@Override public int getItemViewType(int position) { return wrappedAdapter.getItemViewType(position); }

— Reply to this email directly or view it on GitHub https://github.com/felipecsl/AsymmetricGridView/issues/30#issuecomment-105900433 .

supersume commented 9 years ago

I have found a temporary workaround. In the getview() method of my adapter, I don't write the code

if (convertView != null)

The result is that the getview() method will always instantiate a new view hence view recycling is non existent. My guess is, the problem is with views that have been cached by the adapter. The method viewPool.get() in AsymmetricGridViewAdapter.java seems to be returning the wrong view type from cache.