With the new Android 5.0/Lollipop changes, the Actionbar's navigation modes seems to be deprecated, likely due to the new toolbar and related changes.
As seen in the image above, tabbed navigation could be created in prior versions in a rather straightforward manner using an instance of ActionBar and setting the navigation mode like so: ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // New tab Tab tabA = actionBar.newTab(); // Set tab's listener tabA.setTabListener(....); // Adding tab to actionbar actionBar.addTab(tabA); The use of ViewPager with FragmentPagerAdapter is a great alternative, though I did encounter the sort of glitchy behavior as described in this StackOverflow issue: Fragment is blank the second time it is viewed. Switching to FragmentStatePagerAdapter did correct the issue with multiple fragments not loading properly. |
AuthorExploring Android and mobile web design, security, and development. Archives
March 2021
Categories |