Recyclerview Changing Items During Scroll

前端 未结 15 710
我在风中等你
我在风中等你 2020-11-27 10:38

I have a RecyclerView. Each row has a play button, textview and Progressbar. when click on the play button have to play audio from my sdcard and have to progress Progressbar

15条回答
  •  失恋的感觉
    2020-11-27 11:12

    I had the similar issue and searched alot for the right answer. Basically it is more of a design of recycler view that it updates the view on the scroll because it refreshes the view.

    So all you need to do is at the bind time tell it not to refresh it.

    This is how your onBindViewHolder should look like

    @Override
    @SuppressWarnings("unchecked")
    public void onBindViewHolder(final BaseViewHolder holder, final int position) {
        holder.bind(mList.get(position));
    
        // This is the mighty fix of the issue i was having
        // where recycler view was updating the items on scroll.
        holder.setIsRecyclable(false);
    }
    

提交回复
热议问题