我正在使用 firebase-ui
从firebase检索,我想从显示所有等于 unlive
的 status
中删除,我不想从 firebase database
删除它在RecyClerview正在计算布局或滚动时,尝试从recyclerview删除项目时仍遇到错误时,在recyclerview
上显示解决方案也无法调用此方法。请帮助我呆了几天。找不到任何解决方案。谢谢
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());
}
}
如果我滚动到状态为 unlive
position
,这是我的错误 Cannot call this method while RecyclerView is computing a layout or scrolling android.support.v7.widget.RecyclerView
,因此您可以轻松地以这种方式进行:
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删除您的项目。