java - 如何在片段的 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);
}
}
});
}
解决方案
推荐阅读
- typescript - 如何在下一个导航中访问参数
- c++ - 如何在 C++ 类中实现 CreateThread - LPTHREAD_START_ROUTINE 类型的 ThreadProc 回调函数
- python - 根据列值对数据框进行排序
- javascript - 如何在不破坏 html 代码的情况下在 vuejs 模板中循环
- r - 如何从具有符号参数的函数的结果创建方程
- excel - 循环为每一行发送一封电子邮件
- node.js - 使用 axios 在 nodejs 中执行 post 请求,但我无法在 post 路由中接收数据
- javascript - 如何查找数组内的差异值并记录差异的索引
- python - 无法使用 pool.apply_async 通过多处理聚合结果
- swift - Codable 结构中的 Codable 变量导致错误