How do I update a recyclerview project without animation?

I have a recyclerview. When I click the button in the project in recyclerview, I want to change the color of the view in the project. The following is my code, which works normally. However, the problem is that the project will have an ugly animation. I want to update the project without animation. What should I do? By the way, I don't want to close the animation just for this click event

  public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
        public ImageView imageView;
        public Button button;

        public ItemViewHolder(View view) {
            super(view);
            //do something
            button.setOnClickListener(this);
        }

        @Override
        public void onClick(View view) {
            //change color
            notifyItemChanged(getAdapterPosition());
        }
    }

resolvent:

Try this

notifyItemChanged(position, Object);

When we pass an object in it, this will update the position without animating it

Try this and tell me

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>