我正在研究CustomCalendar。 我在Recyclerview中删除了一个事件列表。但是我无法删除calendar(Activity)中的数据。 我该如何触摸此代码?
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
MenuItem add = menu.add(Menu.NONE, 100,1,"수정");
MenuItem remove = menu.add(Menu.NONE,101,2,"삭제");
add.setOnMenuItemClickListener(onEditMenu);
remove.setOnMenuItemClickListener(onEditMenu);
}
private final MenuItem.OnMenuItemClickListener onEditMenu = new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
switch (menuItem.getItemId()){
case 100 :
Toast.makeText(context,"gd",Toast.LENGTH_LONG).show();
break;
case 101 :
arrayList.remove(position);
notifyItemRemoved(position);
notifyItemRangeRemoved(position,arrayList.size());
notifyItemRangeChanged(position,arrayList.size());
break;
}
return true;
}
};
答案 0 :(得分:0)
从阵列中删除后,您是否尝试使用adapter.notifydatasetchanged()