pagination - How to remove footer view in Android? -
i have 3 buttons , i'm displaying pagination button wise. if click on button 1 calling pagination 1 , if click on button 2 start pagination 2nd , if click on button 3rd start pagination 3rd working . have add progress bar @ end of listview setonscrolllistener per pagination.
but problem whenever go end of list view progress bar added every time.i'm tried remove footer view @ last page getting exception of invalid index out of bound exception index 0
.
can me how work pagination progress bar.
1st button click = pegination(); same 2nd button click =loginuser_postloacalpages(); , same 3rd button click = r_post_pagination(); here 1st pagination public void pegination() { final int activitycount = sharedpreferences.getint("activitylistcount", 0); log.e("","activitycount in pegination method ="+activitycount); footer = ((layoutinflater) getsystemservice(context.layout_inflater_service)).inflate(r.layout.prohressbar, listview, false); rlayout = (relativelayout) footer.findviewbyid(r.id.progressrel); progressbar = (progressbar) footer.findviewbyid(r.id.progressbar); btnloadmore = (button) footer.findviewbyid(r.id.btnloadmore); btnloadmore.getlayoutparams().height = 0; progressbar.getlayoutparams().height = 130; btnloadmore.setvisibility(view.gone); progressbar.setvisibility(view.visible); listview.addfooterview(footer); listview.setonscrolllistener(new abslistview.onscrolllistener() { private int total; @override public void onscrollstatechanged(abslistview abslistview, int scrollstate) { } @override public void onscroll(abslistview abslistview, int firstitem, int visibleitemcount, final int totalitems) { total = firstitem + visibleitemcount; log.e("", "total =" + total); if (totalitems > 0 && total > 0 && total == totalitems) { if (prelast != total) { if (pagecount < localpages) { handler handler = new handler(); handler.postdelayed(new runnable() { public void run() { pagecount++; (all_post all_post : alldesc) { descarray.add(all_post); } if (adapter != null) { adapter.notifydatasetchanged(); listview.setadapter(adapter); listview.setselection(totalitems); } } }, 2500); } prelast = total; log.e("", "11111111111 prelast=" + prelast); } prelast = total; log.e("", "222222222222222 prelast=" + prelast); if (pagecount == localpages) { if (prelast == total) { progressbar.setvisibility(view.gone); btnloadmore.setvisibility(view.visible); btnloadmore.setlayoutparams(new relativelayout.layoutparams(relativelayout.layoutparams.match_parent, 60)); pagecount = 0; } } } } } });}
Comments
Post a Comment