我看到了类似的问题,但没有人回答如何从edittext的上下文菜单中删除项目。因此,当我长时间点击edittext时,我会创建我创建的项目,但还有一些我不想出现的项目,例如:选择单词,全选,带字典的内容等。
@Override
public boolean onContextItemSelected(MenuItem item) {
switch(item.getItemId()){
case R.id.white:
Toast.makeText(getApplicationContext(), "white", Toast.LENGTH_LONG).show();
break;
case R.id.red:
Toast.makeText(getApplicationContext(), "red", Toast.LENGTH_LONG).show();
break;
case R.id.green:
Toast.makeText(getApplicationContext(), "green", Toast.LENGTH_LONG).show();
break;
default:
break;
}
return super.onContextItemSelected(item);
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.context, menu);
super.onCreateContextMenu(menu, v, menuInfo);
}