0

i have two fragments,in first fragment i have list of invoice details with check box in list view . i need to store the list items while back from the second fragment

1st fragment:

MakePayment debtorsAging = MakePayment.newInstance();
debtorsAging.setArguments(bundle);

FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

fragmentTransaction.replace(R.id.content_frame, debtorsAging,MakePayment.TAG);

fragmentTransaction.addToBackStack(PaymentCollection.class.getName());
fragmentTransaction.commit();

2nd fragment:

FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction ft=fragmentManager.beginTransaction();
ft.remove(new MakePayment());
ft.commit();
fragmentManager.popBackStackImmediate();

need to restore list of invoices with checked items on go back from makePayment fragment to paymentCollection fragment

Ashish
  • 6,791
  • 3
  • 26
  • 48
  • Possible duplicate of [Passing data back to previous fragment from current fragment](https://stackoverflow.com/questions/42711554/passing-data-back-to-previous-fragment-from-current-fragment) – denvercoder9 Sep 03 '19 at 08:43

1 Answers1

0

If you back to previous activity by onBackPressed (not by transaction) i think you cant pass anythig between fragments by bundle or something. One of resolution I suggest to save id's or something to SharedPreferences before back to previous activity and restore them in first fragment

damienG
  • 409
  • 4
  • 10