开发者

Default ContextMenu showing up along custom ContextMenu

开发者 https://www.devze.com 2023-01-27 02:56 出处:网络
I have created a custom ContextMenu. But when I call the menu, the menu displayed also h开发者_StackOverflow社区as the default menu.

I have created a custom ContextMenu. But when I call the menu, the menu displayed also h开发者_StackOverflow社区as the default menu.

Is there anyway for the default ContextMenu not to appear as well?

Code requested:

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
{
    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater inflater = getMenuInflater();
    menu.setHeaderTitle("Recipients");
    inflater.inflate(R.menu.menu_contacts, menu);
}


Context menu is created by overriding onCreateContextMenu method. If you just inflate a menu from resource there no default menu can appear.

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
{
   menu.setHeaderTitle("Context menu");
   MenuInflater inflater = getMenuInflater();
   inflater.inflate(R.menu.context_menu, menu);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消