Diberdayakan oleh Blogger.

Selasa, 16 September 2014

Hiding ActionBar Tab When Changing Fragment

by Joielechong sipayung  |  in pemrograman visual at  Selasa, September 16, 2014

There is no method like hideTab for hiding ActionBar Tab, but we can achieve the same effect by using ActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD). If we use add fragment when calling a fragment, we must override  onHiddenChange(boolean hidden) fragment method to check if fragment is shown or not then determine to show or hide the tabs.

Here the code in action:

      ActionBar mActionBar;  // get action bar   
     public void onHiddenChanged(boolean hidden) {  
       if (hidden) {  
         //do when hidden  
       } else {  
         //do when show  

This code will detect the fragment status whether hidden or not. If hidden value is true then the Tab will be hidden, if the hidden value is false then the Tab will be show.

Happy Programming ;)


Silahkan tinggalkan komentar anda: