0

I am retrieving object arraylist of a recyclerview item ,my function on the fragment is updated ,but my arraylist on oncreateview remains null, how can i observe the updated value on realtime ?

public void gettolist( ArrayList<Profilefire> profilesingle) {

   profilestoinvoice=profilesingle;
    Log.v("listtocheck",profilestoinvoice.size()+" ");

}

-----> this shows size is updating

 facture.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
              Log.v("listtocheck",profilestoinvoice.size()+" ");

        }
    });

------> but here on the main onCreate method where i am handling my button click,the array keeps showing null

  @Override
  public void onBindViewHolder(@NonNull UserHolderFacture userHolderFacture, int i) {
    final Profilefire profilefire =profiles.get(i);
    userHolderFacture.updateUI(profilefire);

    if (!isSelectedAll) userHolderFacture.checkall(false);
    else userHolderFacture.checkall(true);



    userHolderFacture.getFacturecheck().setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

            if(isChecked){
                profilestoinvoice.add(profilefire);
                invoicingFragment.gettolist(profilestoinvoice);

            }else {
                 profilestoinvoice.remove(profilefire);
                 invoicingFragment.gettolist(profilestoinvoice);

            }



        }
    });



}
joghm
  • 401
  • 2
  • 12
  • how you passing the data to fragment & and some codes then we will understand – Aravind V Mar 28 '19 at 09:16
  • i am calling gettolist function from onBindViewHolder of my adapter, it is list of the objects users checked – joghm Mar 28 '19 at 09:19
  • I just initialized my fragment [ InvoicingFragment invoicingFragment =new InvoicingFragment(); ] and then called my function in the fragment [ invoicingFragment.gettolist(profilestoinvoice); ] – joghm Mar 28 '19 at 09:24
  • May be it's not possible for every fragment of instances – Aravind V Mar 28 '19 at 09:31

0 Answers0