How to pass Bundle from Fragment to Fragment

Solution 1:

In your FragmentA fragment set the bundle as the argument.

Bundle args = new Bundle();
args.putInt("doctor_id",value);    
ListFrag newFragment = new ListFrag ();
newFragment.setArguments(args);

In your ListFrag fragment get the bundle as

Bundle b = getArguments();
int s = b.getInt("doctor_id");

Solution 2:

Fragment to Fragment set and get Argument:

Start Activity :

     int friendId = 2; //value to pass as extra 
     i = new Intent(firstActivity, SecondActivity.class);
     i.putExtra("friendsID", friendId);
     firstActivity.startActivity(i);

SecondActivity:

     Fragment_A mFragment_A = new Fragment_A();
     mFragment_A.setArguments(getIntent().getExtras());

Fragment_A:

    Bundle bundle = new Bundle();
    String Item = getArguments().getString("friendsID");
    bundle.putInt("friendsID", Integer.parseInt(Item));

    // code

    Fragment_B mFragment_B = new Fragment_B();
    mFragment_B.setArguments(bundle);

Fragment_B:

    Bundle bundle = getArguments();
    int value = bundle.getInt("friendsID");

    Log.e("value Fragment get Argument ", "friendsID :" + value);

this work for me,try this may be this sample help you.