场景:我在 recyclerview 中有 5 个数据,并尝试添加addOnItemTouchListener. 首先在 1 到 3 RecyclerView Row 中运行良好。但是,如果我单击 4 和 5 行,则会出现该异常。
代码:
mRecyclerView.addOnItemTouchListener(new RecyclerTouchListener(getActivity(), mRecyclerView, new RecyclerTouchListener.ClickListener() {
@Override
public void onClick(View view, int position) {
DaftarPengumuman pengumuman = listPengumuman.get(position-1);
Intent intent = new Intent(getActivity(), DetailPengumuman.class);
// intent.putExtra("keys", keys.get(position));
intent.putExtra("namamatkul", namaMatkulPut.get(position-1));
intent.putExtra("namapengumuman", namaPengumumanPut.get(position-1));
intent.putExtra("tanggalpengumuman", tanggalPengumumanPut.get(position-1));
intent.putExtra("judulpengumuman", judulPengumumanPut.get(position-1));
intent.putExtra("deskripsipengumuman", deskripsiPengumumanPut.get(position-1));
startActivity(intent);
}
@Override
public void onLongClick(View view, int position) {
}
}));
在我在位置上做 -1 之前,异常说:
java.lang.IndexOutOfBoundsException: Invalid index 6, size is 5
慕尼黑5688855
绝地无双
神不在的星期二
相关分类