android - Add tabs in a View Pager -
how can add tabs swipeview fragments?
here oncreate method of main activity in 2 fragments initialized:
myfragmentpageradapter pageradapter; /** * pager adapter, provides pages view pager widget. */ viewpager pager = null; myfragmentpageradapter adapter = null; @override protected void oncreate(bundle arg0) { super.oncreate(arg0); this.setcontentview(r.layout.activity_main); // instantiate viewpager this.pager = (viewpager) this.findviewbyid(r.id.pager); // set custom animation this.pager.setpagetransformer(true, new depthpagertransformer()); // create adapter fragments show on viewpager this.adapter = new myfragmentpageradapter( getsupportfragmentmanager()); this.adapter.addfragment(inactivitypagefragment.newinstance(getresources() .getcolor(r.color.red), 0)); this.adapter.addfragment(listactivitiespagefragment.newinstance(getresources() .getcolor(r.color.white), 1)); this.pager.setadapter(adapter); }
Comments
Post a Comment