popbackstack fragment how to pass value in bundle code example

Example 1: popbackstack fragment how to pass value in bundle

FragmentManager fm = getActivity().getFragmentManager();
Bundle arguments = new Bundle();
arguments.putInt("VALUE1", 0);
arguments.putInt("VALUE2", 100);

MyFragment myFragment = new Fragment();
fragment.setArguments(arguments);

fm.beginTransaction().replace(R.id.content_frame, myFragment).commit();

Example 2: popbackstack fragment how to pass value in bundle

FragmentTransaction ft = getActivity().getFragmentManager().beginTransaction();
    FragmentB frgamentB = new FrgamentB();
    fragmentB.setTargetFragment(FrgamentA.this, AppConstant.FRAGMENT_CODE);
    ft.addToBackStack(fragment.getClass().getName());
    ft.add(R.id.content, fragment, tag);
    ft.commit();

Tags:

Misc Example