Code example for FragmentActivity

Methods: getSupportFragmentManager, onRestoreInstanceState

0
        updateFragmentVisibility(); 
    } 
 
    @Override 
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        // Make sure fragments are updated after check box view state is restored. 
        updateFragmentVisibility(); 
    } 
 
    // Update fragment visibility based on current check box state. 
    void updateFragmentVisibility() { 
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        if (mCheckBox1.isChecked()) ft.show(mFragment1);
        else ft.hide(mFragment1);
        if (mCheckBox2.isChecked()) ft.show(mFragment2);
        else ft.hide(mFragment2);
        ft.commit();
    } 
 
    /**