Code example for MenuItem

Methods: getItemId, getMenuInfo

0
 
 
    @Override 
    public boolean onContextItemSelected(MenuItem item) {
      AdapterView.AdapterContextMenuInfo info =
              (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
      if (info.position >= mFiles.size()) {
        return true; 
      } 
      int id = item.getItemId();
      switch (id) {
          case SYSTEM_LOG_ID: // drop down
          case MEMORY_ID:     // drop down
          case CPU_ID:        // drop down
          case PROCRANK_ID:
          File file = mFiles.get(info.position);
          Intent intent = new Intent(Intent.ACTION_VIEW);
          intent.setDataAndType(Uri.fromFile(file), "vnd.android/bugreport");
          intent.putExtra("section", ID_MAP.get(id));
          startActivity(intent);
          return true;