NotifyItemRemoved无法使用firebaserecycleradapter正常工作?

时间:2019-03-20 06:07:25

标签: android firebase android-recyclerview firebaseui

我正在使用 C1 C2 C3 C2 0.6 C3 0.7 0.4 C4 0.5 0.9 0.3 从firebase检索,并且我想从显示等于firebase-ui的所有status中删除,我不想从{{ 1}},但仅将其从unlive上删除,并尝试执行解决方案Cannot call this method while RecyclerView is computing a layout or scrolling when try remove item from recyclerview,此处仍然遇到错误。请帮助我在这里待几天。找不到任何解决方案。谢谢

firebase database

如果我滚动到状态为recyclerview的{​​{1}},这是我的错误

mAdapter = new FirebaseRecyclerAdapter<Hotels_Model, Adapter_HotelsHolder>(mOptions) {
            @Override
            protected void onBindViewHolder(Adapter_HotelsHolder holder,int position, Hotels_Model model) {

                String status = model.getStatus();
                if (status.equals("unlive")) {
                    mAdapter.notifyItemRemoved(holder.getAdapterPosition());
                    mAdapter.notifyItemRangeChanged(holder.getAdapterPosition(), getItemCount());
                }

        }

1 个答案:

答案 0 :(得分:0)

因此,您可以通过这种方式轻松实现:

mAdapter = new FirebaseRecyclerAdapter<Hotels_Model, Adapter_HotelsHolder>(mOptions) {
            @Override
            protected void onBindViewHolder(Adapter_HotelsHolder holder,int position, Hotels_Model model) {

                String status = model.getStatus();
                if (status.equals("unlive")) {
                  holder.yourRowView.setVisibility(View.GONE);
                }

        }

您不需要从recyclerview中删除商品。