[android]代码库
//上下文注册菜单
registerForContextMenu(list);
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
// TODO Auto-generated method stub
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderIcon(new Color().BLUE);
menu.setHeaderTitle("");
menu.add(0, 1, 0, "删除");
}
@Override
public boolean onContextItemSelected(MenuItem item) {
// TODO Auto-generated method stub
AdapterContextMenuInfo adapterc=(AdapterContextMenuInfo) item.getMenuInfo();
int id=adapterc.position;
switch (item.getItemId()) {
case 1:
data.remove(id);
b.notifyDataSetChanged();
break;
}
return super.onContextItemSelected(item);
}
by: 发表于:2017-10-18 09:19:46 顶(0) | 踩(0) 回复
??
回复评论