Refresh on swiping tabs android -


i using view pager , fragments. have 3 swipable tabs. each extend fragment. want them refresh them on swipe. how achieve this? when swipe, tab not refreshed.

public class orders extends fragmentactivity implements     actionbar.tablistener {  private viewpager viewpager; private tabspageradapter madapter; private actionbar actionbar; // tab titles private string[] tabs = { "pending", "completed", "rejected" };  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_orders);     this.settitle((html.fromhtml("<font color=\"#ffffff\">" + "pharmeazy-mobile" + "</font>")));     // initilization     viewpager = (viewpager)findviewbyid(r.id.pager1);     madapter = new tabspageradapter(getsupportfragmentmanager());     actionbar=getactionbar();     getactionbar().setbackgrounddrawable(new colordrawable(color.parsecolor("#69acdf")));     viewpager.setadapter(madapter);     actionbar.setnavigationmode(actionbar.navigation_mode_tabs);              // adding tabs     (string tab_name : tabs) {         actionbar.addtab(actionbar.newtab().settext(tab_name)                 .settablistener(this));     }      /**      * on swiping viewpager make respective tab selected      * */     viewpager.setonpagechangelistener(new viewpager.onpagechangelistener() {          @override         public void onpageselected(int position) {             // on changing page             // make respected tab selected             actionbar.setselectednavigationitem(position);         }          @override         public void onpagescrolled(int arg0, float arg1, int arg2) {         }          @override         public void onpagescrollstatechanged(int arg0) {         }     }); }  @override public void ontabreselected(tab tab, fragmenttransaction ft) { }  @override public void ontabselected(tab tab, fragmenttransaction ft) {     // on tab selected     // show respected fragment view     viewpager.setcurrentitem(tab.getposition()); }  @override public void ontabunselected(tab tab, fragmenttransaction ft) { } 

please help

dont use actionbar. take @ tablayout new layout viewpager tabs google released in last support update. solve issue


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -