android.view.ContextMenu.removeItem()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中android.view.ContextMenu.removeItem()方法的一些代码示例,展示了ContextMenu.removeItem()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ContextMenu.removeItem()方法的具体详情如下:
包路径:android.view.ContextMenu
类名称:ContextMenu
方法名:removeItem

ContextMenu.removeItem介绍

暂无

代码示例

代码示例来源:origin: renyuneyun/Easer

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
  if (v == listView) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.list_context, menu);
    menu.removeItem(R.id.action_edit);
  }
}

代码示例来源:origin: derry/delion

private void removeUnsupportedItems(ContextMenu menu, int[] whitelist) {
  Arrays.sort(BASE_WHITELIST);
  Arrays.sort(whitelist);
  for (int i = 0; i < menu.size(); i++) {
    MenuItem item = menu.getItem(i);
    if (Arrays.binarySearch(whitelist, item.getItemId()) < 0
        && Arrays.binarySearch(BASE_WHITELIST, item.getItemId()) < 0) {
      menu.removeItem(item.getItemId());
      i--;
    }
  }
}

代码示例来源:origin: labexp/osmtracker-android

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
  super.onCreateContextMenu(menu, v, menuInfo);
  getMenuInflater().inflate(R.menu.trackmgr_contextmenu, menu);
  
  long selectedId = ((AdapterContextMenuInfo) menuInfo).id;
  menu.setHeaderTitle(getResources().getString(R.string.trackmgr_contextmenu_title).replace("{0}", Long.toString(selectedId)));
  if(currentTrackId == selectedId){
    // the selected one is the active track, so we will show the stop item
    menu.findItem(R.id.trackmgr_contextmenu_stop).setVisible(true);
  }else{
    // the selected item is not active, so we need to hide the stop item
    menu.findItem(R.id.trackmgr_contextmenu_stop).setVisible(false);
  }
  menu.setHeaderTitle(getResources().getString(R.string.trackmgr_contextmenu_title).replace("{0}", Long.toString(selectedId)));
  if ( currentTrackId ==  selectedId) {
    // User has pressed the active track, hide the delete option
    menu.removeItem(R.id.trackmgr_contextmenu_delete);
  }
}

相关文章