android - How to set OnPageChangeListener for Multiple ViewPagers -
i using loop define viewpagers:
linearlayout llmain; pageradapter[] padapter = new pageradapter[20]; viewpager[] pager = new viewpager[20]; for(int i=0;i<20;i++){ padapter[i] = new awesomepageradapter(); pager[i] = new viewpager(this); pager[i].setadapter(padapter[i]); ifinawesomepager[i].setonpagechangelistener(new onpagechangelistener() { @override public void onpagescrollstatechanged(int arg0) {} @override public void onpagescrolled(int arg0, float arg1, int arg2) {} @override public void onpageselected(int arg0) { //which 1 of viewpagers has been changed here? } }); llmain.addview(pager[i]); }
how know 1 of viewpagers changed in onpagechangelistener() ?
thanks!
i using loop define viewpagers
that unusual pattern.
how know 1 of viewpagers changed in onpagechangelistener() ?
create class implements onpagechangelistener
. have class take viewpager
in constructor , hold onto value in data member. use class instead of current anonymous inner class attaching listener pager.
Comments
Post a Comment