Answer the question
In order to leave comments, you need to log in
Why is data shuffled in RecyclerView?
I have a RecyclerView with a list of jobs. After clicking "execute", the following code is triggered:
listItemTask.remove(position);
notifyItemRemoved(position);
notifyItemRangeChanged(position, listItemTask.size());
public void onBindViewHolder(@NonNull final ViewHolder holder, @SuppressLint("RecyclerView") int p) {
int position = holder.getAdapterPosition();
ItemTask task = listItemTask.get(position);
holder.titleTask.setText(task.getTitle() + ""); // не заменяется
if (task.getDeadline().equals("Без дедлайна")) { // заменяется
holder.deadlineLayout.setVisibility(View.GONE);
} else {
holder.deadlineTask.setText(task.getDeadline() + "");
}
holder.numberCoinsTask.setText(task.getRewardCoins() + ""); // не заменяется
holder.numberProgressTask.setText(task.getRewardProgress() + ""); // не заменяется
iconHelper = new IconHelper(task.getAttributeImproveSkill(), task.getImportance());
holder.iconImproveSkill.setBackgroundResource(iconHelper.getBg()); // не заменяется
if (task.getIdImproveSkill() == -1) { // заменяется
holder.titleImproveSkill.setText("Без улучшаемого навыка");
holder.improveSkillLayout.setVisibility(View.GONE);
holder.iconImproveSkill.setImageResource(R.drawable.icon_standart);
} else { // тоже заменяется
holder.titleImproveSkill.setText(task.getTitleImproveSkill());
holder.iconImproveSkill.setImageResource(IconHelper.iconRes[task.getIconImproveSkill()]);
holder.pointsAttribute.setText(task.getPointsAttributeImproveSkill() + "");
holder.iconAttribute.setImageResource(iconHelper.getIconAttribute());
holder.pointsAttribute.setVisibility(View.VISIBLE);
holder.iconAttribute.setVisibility(View.VISIBLE);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question