Search code examples
androidtabsactionbarsherlockandroid-holo-everywhere

actionbar does not refresh tab selection


I use a TabSwipeFragment from HoloEverywhere. In this, I use 3 tabs.

The third tab should not be accessible every time. So I use a TabSelectedListener to check this:

this.setOnTabSelectedListener(new OnTabSelectedListener(){

    @Override
    public void onTabSelected(int position) {
        switch(position){
            case 0:
            default:
                break;      
            case 1:
                break;      
            case 2:
                if(PlayerPage.accessable!=1) {
                    getSupportActionBar().setSelectedNavigationItem(1);
                }
            break;
        }           
    }         
});

The Fragment Tab is changed properly, but the Navigation not. The third "PlayerPage" is marked blue, as this is selected.


Solution

  • Runnable tryThis = new Runnable(){
    
        @Override
        public void run() {
            getSupportActionBar().setSelectedNavigationItem(1);
        }
    
    };
    Handler handler=new Handler();
    handler.post(tryThis);
    

    Using this method worked.