首页 > 解决方案 > 如何在片段的 onCreateview 上更新我的对象数组列表

问题描述

我正在检索 recyclerview 项目的对象数组列表,我在片段上的函数已更新,但我在 oncreateview 上的数组列表仍然为空,我如何实时观察更新的值?

public void gettolist( ArrayList<Profilefire> profilesingle) {

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

}

-----> 这表明尺寸正在更新

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

        }
    });

------> 但是在我处理按钮单击的主要 onCreate 方法上,数组一直显示为 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);

            }



        }
    });



}

标签: javaandroid

解决方案


推荐阅读