How To Start A Fragment From Spinner In Action Bar?
i have got an app with Sliding Drawer,15 Fragments(Swipe) Tabs With View Pager Numbered 1-15,Spinner In Action Bar,View Pager For Showing The 15 Fragments What I Need Is When i sel
Solution 1:
when user select spinner item you must do these steps:
first find the TabbedActivity
by calling
TabbedActivityf= (TabbedActivity) getSupportFragmentManager().findFragmentById(TabbedActivity.Tag);
then you must get viewpager
in that fragment, you can use getter
-setter
or declare it public
, i assume getter
approach:
f.getViewPager().setCurrentItem(the position you want to go, false);
so your code must be something like:
be careful you have two TabbedActivity
and i do not know which one is showing so you must select the correct one in the below code:
@OverridepublicbooleanonNavigationItemSelected(int position, long arg1) {
TabbedActivityf= (TabbedActivity) getSupportFragmentManager().findFragmentById(TabbedActivity.Tag);
f.getViewPager().setCurrentItem(position, false);
returntrue;
}
Post a Comment for "How To Start A Fragment From Spinner In Action Bar?"