看起来 onCreateContextMenu 根本没有被调用。在我的 ListActivity 的 onCreate 中,我有:
list = getListView();
registerForContextMenu(list);
(我知道这是多余的,我刚刚通过 getListView() 得到了相同的结果)。
这是我的 onCreateOntextMenu;
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
Log.d("LM", "onCreateContextMenu");
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.context_landmarks, menu);
}
日志永远不会生成。没有人有任何建议吗?
最佳答案
我的想法是 ListView 拦截事件而不进入 contextMenu 行为。这对我来说很有意义,因为 OnItemLongClickListener 的行为与 contextMenu 的行为重叠。如果不是,它如何识别 contextMenu 和 OnItemLongClickListener?
关于android - onCreateContextMenu 未被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9057015/