android - StickyGridHeaders custom adapter -


i'm trying implement own stickygridheadersbaseadapter, current source code here - http://paste.org.ru/?11jrjh, , use like

modeadapter adapter = new modeadapter(this); modegridview.setadapter(adapter); 

problems have that

1) have no idea how call notifydatasetchanged() adapter, can't change items

2) , implementation of adapterview.onitemclicklistener (http://paste.org.ru/?mvgt7b) works strange

mode mode = (mode) adapter.getitem(position); 

returns null items 1st , 2nd positions, item on 3rd position actual 1st item in adapter.

where fault here?

one more question why can't cast adapterview.getadapter() in onitemclicklistener modeadapter class.

what if want call notifydatasetchanged() here? didn't find examples custom implementation of stickygridheadersbaseadapter here.

thanks in advance.

i had same issue 2):

after first header got item of previous row, after second header got item of 2 rows up, etc...

the reason following:

stickyheadersgridview:

@override public void onitemclick(adapterview<?> parent, view view, int position, long id) {     monitemclicklistener.onitemclick(parent, view, madapter.translateposition(position).mposition, id); } 

the position corrected. in onitemclick corrected value of position.

if request item with: mode mode = (mode) adapter.getitem(position); stickygridheadersbaseadapterwrapper.getitem(int pos)

@override public object getitem(int position) throws arrayindexoutofboundsexception {     position adapterposition = translateposition(position);     if (adapterposition.mposition == position_filler || adapterposition.mposition == position_header) {         // fake entry in view.         return null;     }     return mdelegate.getitem(adapterposition.mposition); } 

in stickygridheadersbaseadapterwrapper.getitem() position gets corrected second time causes wrong item returned...

i added work-around:

in stickyheadersbaseadapterwrapper added:

public object getitematdelegateposition(int pos) {     return mdelegate.getitem(pos); } 

and use in onitemclick:

mode item = (mode) ((stickygridheadersbaseadapterwrapper)parent.getadapter()).getitematdelegateposition(position); 

Comments