I have fragment A, B, C, D inside a viewpager. I want to hide the actionbar in fragment A and show the actionbar for the rest of the fragments.
Any Ideas? Thanks.
Edit: Tried the following and still had the actionbar show up in all the fragments.
@Override
public void onPageSelected(int position) {
if (position == 0) {
mActionBar.hide();
} else {
mActionBar.show();
}
}
Pretty much when you open the activity with the viewpager I am want Fragment A to show up with no actionbar but when i swipe to view the other fragments I want the actionbar to be shown.
In Fragments you want to show the Action Bar :
@Override
public void onResume() {
super.onResume();
actionBar.show();
}
In Fragments you dont want to show the Action Bar :
@Override
public void onResume() {
super.onResume();
actionBar.hide();
}
For a ViewPager :
viewPager.setOnPageChangeListener(new OnPageChangeListener() {
@Override
public void onPageSelected(int selectedPage) {
// Check the selectedPage here and then show and
// hide the actionBar accordingly.
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
}
@Override
public void onPageScrollStateChanged(int arg0) {
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.