我有一个包含6个项目的列表。我可以使用hinterArrayList.remove(position);来删除hinterLv.setOnMenuItemClickListener内的listview项目。 。没关系。但对于前。如果我将列表中的第二个元素删除,则第三个元素变为第二个,则仍会为其显示滑动动画,并且单击事件不起作用。我尝试了smoothClose()方法和clearAnimation(),但是没有用。它只适用于最后一项bcz,没有该索引的元素,因此如果我删除5(last)没有5索引项,那么动画仍然显示,但对于其他滑动动画仍然显示。对不起,我的英语。
我的印象:'com.baoyz.swipemenulistview:library:1.3.0'
Android版本:3.3
for (int i = 0; i < 6; i++) {
Reminder reminder = new Reminder();
reminder.setDate(calendar.getTime());
calendar.add(Calendar.DAY_OF_WEEK, -2);
calendar.add(Calendar.HOUR, -1);
calendar.add(Calendar.MINUTE, -12);
if (i == 0) reminder.setProcessName(getResources().getString(R.string.stationcasco));
if (i == 1) reminder.setProcessName(getResources().getString(R.string.tankcleaning));
if (i == 2) reminder.setProcessName(getResources().getString(R.string.tankcalibration));
if (i == 3)
reminder.setProcessName(getResources().getString(R.string.automationmaintenance));
if (i == 4)
reminder.setProcessName(getResources().getString(R.string.firetubemaintenance));
if (i == 5) reminder.setProcessName(getResources().getString(R.string.other));
reminderArrayList.add(reminder);
}
reminderListAdapter = new ReminderListAdapter(this, reminderArrayList);
reminderLv.setAdapter(reminderListAdapter);
// Right
reminderLv.setSwipeDirection(SwipeMenuListView.DIRECTION_LEFT);
creator = new SwipeMenuCreator() {
@Override
public void create(SwipeMenu menu) {
// create "delete" item
SwipeMenuItem deleteItem = new SwipeMenuItem(
getApplicationContext());
// set item background
deleteItem.setBackground(new ColorDrawable(Color.rgb(0xF9,
0x3F, 0x25)));
// set item width
deleteItem.setWidth(dp2px(90));
// set a icon
deleteItem.setIcon(R.drawable.ic_cancel_white_24dp);
// add to menu
menu.addMenuItem(deleteItem);
}
};
// set creator
reminderLv.setMenuCreator(creator);
reminderLv.setOnMenuItemClickListener(new SwipeMenuListView.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(int position, SwipeMenu menu, int index) {
reminderArrayList.remove(position);
Collections.sort(reminderArrayList, new Comparator<Reminder>() {
@Override
public int compare(Reminder o1, Reminder o2) {
return o1.getDate().compareTo(o2.getDate());
}
});
Collections.reverse(reminderArrayList);
reminderListAdapter.notifyDataSetChanged();
Snackbar.make(remindermainlayout, "İşlem Başarılı", Snackbar.LENGTH_SHORT).show();
return false;
}
});