Skip to content Skip to sidebar Skip to footer

Switch Between Two Fragments

I want to do the following. There are two fragments first and second. Necessary make the transition between them. When I go from first fragment in the second, first stored in the s

Solution 1:

I solved this problem :). I hide first fragment and add transaction to the back stack. When I click button Back I return to fragment

@Override 
public void onNavigate() { 
    FragmentTransaction ft = getFragmentManager().beginTransaction(); 
    Fragment1 newFragment1 = (Fragment1) getFragmentManager().findFragmentByTag("frag_1"); 
    ft.hide(newFragment1); 
    ft.addToBackStack(null); 
    ft.commit(); 
}

Post a Comment for "Switch Between Two Fragments"