how to set default fragment android studio? -
hello every body made weather application , have 3 tabs want make tab 2 default tab when run app
that's code :
public class sectionspageradapter extends fragmentpageradapter { public sectionspageradapter(fragmentmanager fm) { super(fm); } @override public fragment getitem(int position) { switch (position) { case 0: tab1 tab1=new tab1(); return tab1; case 1: tab2 tab2=new tab2(); return tab2; case 2: tab3 tab3=new tab3(); return tab3; } return null; } @override public int getcount() { // show 3 total pages. return 3; } @override public charsequence getpagetitle(int position) { switch (position) { case 0: return "nextday"; case 1: return "today"; case 2: return "3rd day"; } return null; } }
in host activity, @ end of oncreate call mviewpager.setcurrentitem(1);
Comments
Post a Comment