我一直在关注这个链接的指南"使用RecyclerView拖动和滑动 - 由IPaulPro",我在某些情况下遇到的问题很少.
所以,我基本上完成了他解释的所有内容+我在项目中添加了一个TextView,表示RecyclerView中项目的位置,如下所示:

一切都很好看,除非我开始"快速射击"物品,然后我有两个问题:
我所做的也是notifyAdapterSetChanged()在
onItemClear()方法中使用- 它以某种方式修复它,但导致了
IllegalStateException捕获 - 会导致
IndexOutOfBounds异常.
我将在下面粘贴我的整个适配器代码,其中必须存在缺陷.
LayoutInflater inflater;
Context context;
AndroidEntityQuestionResult androidEntityQuestionResult;
ArrayList<AndroidEntityAnswer> list = new ArrayList<>();
ORDLayoutManagerQuestion ord;
ScreenDimensionsConstants sdc;
public OrderingRecycleAdapter(Context context, AndroidEntityQuestionResult androidEntityQuestionResult, ORDLayoutManagerQuestion ord) {
inflater = LayoutInflater.from(context);
this.context = context;
this.list = androidEntityQuestionResult.getAndroidEntityQuestion().getEntityAnswer();
this.androidEntityQuestionResult = androidEntityQuestionResult;
this.ord = ord;
sdc = new ScreenDimensionsConstants(context);
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = inflater.inflate(R.layout.custom_row_ordering_rv, parent, false);
final …Run Code Online (Sandbox Code Playgroud)