-2

I am trying to pass arraylist from activity to fragments but i am getting a null value using the parceable.

In Main Activity:

Bundle bundle = new Bundle();
                    bundle.putParcelableArrayList("cbookings", customerbooking);
                    Todaybooking tb = new Todaybooking();
                    tb.setArguments(bundle);

Array list data declarations

ArrayList<Cbooking> customerbooking = new ArrayList<>();

In fragments:

ArrayList<Cbooking> customerbooking = new ArrayList<>();

    Bundle extras = getActivity().getIntent().getExtras();
    customerbooking = extras.getParcelableArrayList("cbookings");
    Log.wtf("test", customerbooking.toString());
AXIES
  • 13
  • 5

1 Answers1

1

You are using setArguments() to pass the data into the fragment. Therefore, you need to use getArguments() to retrieve the data, not getActivity().getIntent().getExtras().

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491