Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
supersume opened this issue May 20, 2015 · 3 comments

Comments

@supersume
Copy link

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
Copy link

RoRoche commented May 27, 2015

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
Copy link
Author

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
#30 (comment)
.

@supersume
Copy link
Author

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.

felipecsl added a commit that referenced this issue Jun 18, 2015
Initial fix for multiple adapter view types (issue #30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants