Skip to content Skip to sidebar Skip to footer

MergeAdapter With Gridview

Libraries: https://github.com/commonsguy/cwac-merge https://github.com/maurycyw/StaggeredGridView https://github.com/chrisbanes/Android-PullToRefresh I'd like to add a gridview a

Solution 1:

addView() on MergeAdapter is designed for ListView headers and the like. You, instead, are attempting to put a GridView as an element inside of some other AdapterView that is using the MergeAdapter. That is not supported by MergeAdapter, and putting a GridView inside of another AdapterView is unlikely to work no matter how you try to do it.

Also, I do not recommend making an Adapter be static, and certainly not a MergeAdapter, as it would represent a significant memory leak (and is unnecessary in the first place).


Solution 2:

You problem is very generic. As in your code

private static MergeAdapter adapter = null;
adapter.addView(buildlabel3(context));

adapter is null, and not initialised. So whatever you add to it, it still null.

I have seen the soucre code of MergeAdapter. It has a constructor:

public MergeAdapter() {
    super();
}

So just change your code to

private static MergeAdapter adapter = new MergeAdapter();
adapter.addView(buildlabel3(context));

and then try again.


Post a Comment for "MergeAdapter With Gridview"