Android - hiding ActionBar icon and title during launch
I was developing an app that had a tabbed interface (FragmentPagerAdapter) inside the main activity. Each tab was setting different ActionBar icon and title inside onTabSelected method. Something like this:
@Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) { viewPager.setCurrentItem(tab.getPosition()); if (tab.getPosition() == 0){ actionBar.setTitle("title1"); actionBar.setIcon(R.drawable.icon1); } if (tab.getPosition() == 1) { actionBar.setTitle("title2"); actionBar.setIcon(R.drawable.icon2); } if (tab.getPosition() == 2) { actionBar.setTitle("title3"); actionBar.setIcon(R.drawable.icon3); } }
This was working fine when the app was running and resuming from paused. But on the initial launch, global application icon and title was appearing inside ActionBar for half a second or so, before being overridden by the code in onTabSelected .
Read more: Android - hiding ActionBar icon and title during launch