Код: Выделить всё
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
int pos = holder.getBindingAdapterPosition();
ExamItem examItem = examList.get(pos);
holder.examName.setText(examItem.getName());
holder.itemView.setOnClickListener(v -> {
holder.itemView.setBackgroundColor(Color.RED); // just for testing
// Toast.makeText(v.getContext(), "pos: "+pos, Toast.LENGTH_SHORT).show();
if (pos > 0 && pos < getItemCount()) {
examList.remove(pos);
examList.add(0, examItem);
notifyItemMoved(pos, 0);
}
});
}
Код: Выделить всё
// Activity or Fragment
private List ExamItems = new ArrayList();
for (int i=0; i
Подробнее здесь: [url]https://stackoverflow.com/questions/79791231/recyclerview-item-move-animation-and-strange-behavior-of-on-item-click[/url]
Мобильная версия