Created
June 14, 2013 21:54
-
-
Save wesleyfsmith/5785589 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void selectTab(int itemPosition) { | |
| //hide whatever was previously showing | |
| hideCurrentFragment(); | |
| currentTab = availableTabs.get(itemPosition); | |
| //haven't determined where to go yet | |
| if (currentTab == null) { | |
| return; | |
| } | |
| //set animation here | |
| showFragment(tabFragments.get(currentTab.getLabel())); | |
| } | |
| private void showDefaultTab() { | |
| //create fragments | |
| createFragments(); | |
| try { | |
| selectTab(getString(R.string.home)); | |
| } catch (IndexOutOfBoundsException e) { | |
| //catch this exception, and keep navigation item | |
| //null if we don't have any tabs | |
| hideLoadingMessages(); | |
| showErrorMessage(); | |
| //kick them off the current fragment | |
| hideCurrentFragment(); | |
| currentTab = null; | |
| } | |
| //if the list has where we want to go | |
| if (availableTabs.contains(currentTab)) { | |
| hideLoadingMessages(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment