我正在调用方法notifyItemChanged(position,payload),并且当我选择一个新视图时,通过将视图刷新到其正常状态,它可以正常工作。但是,我进行了一些测试,发现当我向下滚动直到看不到它时,notifyItemChanged(position,payload)不会刷新该位置的视图。因此,当我备份时,我发现它没有改变。
@Override
public void onBindViewHolder(@NonNull TrackHolder holder, int position, @NonNull List<Object> payloads) {
if(!payloads.isEmpty()) {
if (payloads.get(0) instanceof Boolean) {
holder.mMusicSeekbar.setEnabled((Boolean) payloads.get(0));
holder.mPlayButton.change(!(Boolean) payloads.get(0));
}
}else {
super.onBindViewHolder(holder,position, payloads);
}
}
@Override
public void onBindViewHolder(@NonNull final TrackHolder holder, final int position) {
holder.mInstrumentalName.setText(tracks.get(position).getInstrumentalName());
holder.mProducer.setText(tracks.get(position).getProducer());
holder.mPlayButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (start_notifying > 0) {
notifyItemChanged(previous_position, false);
previous_position = holder.getAdapterPosition();
holder.mPlayButton.change(false);
} else {
start_notifying++;
holder.mPlayButton.change(false);
previous_position = holder.getAdapterPosition();
}