删除商品时,我在回收者视图中有一个错误

时间:2019-01-02 18:00:52

标签: java android android-recyclerview

项目被删除“我对此没有问题”

但问题是检查动画 当删除项目被删除时,已删除项目下面的项目的检查动画将被取消选中(如果已选中) 这是因为物品的位置变得井井有条 enter image description here idk发生了什么

我是Java新手 这是我的removeitem函数

 public void removeAt(int position) {
    dbhelper.deletecoloumn(listTask.get(position).getID());
    dbhelper.deleteallitem(listTask.get(position).getID());
    listTask.remove(position);
    notifyItemRangeChanged(position, getItemCount());
    notifyItemRemoved(position);
}

checkanim函数

  private void Check(TaskHolder holder,int position){
    if (listTask.get(position).getComplete().equals("0")){
        Log.d(TAG, "Check: equals 0");
        holder.uncheckeditem.setVisibility(View.VISIBLE);
        holder.checked.setVisibility(View.GONE);
        holder.textViewName.setTextColor(mContext.getResources().getColor(R.color.black));
        holder.textViewName.setPaintFlags(holder. textViewName.getPaintFlags() & (~ Paint.STRIKE_THRU_TEXT_FLAG));
    }else if (listTask.get(position).getComplete().equals("1")){
        holder.uncheckeditem.setVisibility(View.GONE);
        Log.d(TAG, "Check: equals 1");
        holder.checked.setVisibility(View.VISIBLE);
        holder.textViewName.setPaintFlags( holder.textViewName.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        holder.textViewName.setTextColor(mContext.getResources().getColor(R.color.text_grey));
    }
}

0 个答案:

没有答案