android - MergeAdapter with Gridview -
libraries:
- https://github.com/commonsguy/cwac-merge
- https://github.com/maurycyw/staggeredgridview
- https://github.com/chrisbanes/android-pulltorefresh
i'd add gridview adapter mergeadapter.
1st way, if set adapter:
plv = (pulltorefreshlistview) layoutinflater.from(context).inflate( r.layout.layout_listview_in_viewpager, container, false); adapter = new mergeadapter(); sadapter = new staggeredadapter(basesampleactivity.this, r.id.imageview1, urls); adapter.addadapter(sadapter); plv.setadapter(adapter);
then works list view.
2nd way, if build view:
plv = (pulltorefreshlistview) layoutinflater.from(context).inflate( r.layout.layout_listview_in_viewpager, container, false); adapter = new mergeadapter(); adapter.addview(buildlabel3(context)); plv.setadapter(adapter); public view buildlabel3(context context) { // todo auto-generated method stub relativelayout v = (relativelayout)layoutinflater.from(context).inflate(r.layout.activity_main, null); staggeredgridview gridview = (staggeredgridview) v.findviewbyid(r.id.staggeredgridview1); int margin = getresources().getdimensionpixelsize(r.dimen.margin); gridview.setitemmargin(margin); // set gridview margin gridview.setpadding(margin, 0, margin, 0); // have margin on sides staggeredadapter sadapter = new staggeredadapter(basesampleactivity.this, r.id.imageview1, urls); gridview.setadapter(sadapter); sadapter.notifydatasetchanged(); log.e("view", v.tostring()); return v; }
then doesn't show , no error.
addview()
on mergeadapter
designed listview
headers , like. you, instead, attempting put gridview
element inside of other adapterview
using mergeadapter
. not supported mergeadapter
, , putting gridview
inside of adapterview
unlikely work no matter how try it.
also, not recommend making adapter
static
, , certainly not mergeadapter
, represent significant memory leak (and unnecessary in first place).
Comments
Post a Comment