android.view.MenuItem.getItemId()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(152)

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

暂无

代码示例

代码示例来源:origin: stackoverflow.com

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  MenuInflater inflater = getSupportMenuInflater();
  inflater.inflate(R.menu.main, menu);
  return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {

    case R.id.activity_menu_item:

      // Do Activity menu item stuff here
      return true;

    case R.id.fragment_menu_item:

      // Not implemented here
      return false;
    default:
      break;
  }

  return false;
}

代码示例来源:origin: PhilJay/MPAndroidChart

@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
    case R.id.viewGithub: {
      Intent i = new Intent(Intent.ACTION_VIEW);
      i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/FilledLineActivity.java"));
      startActivity(i);
      break;
    }
  }
  return true;
}

代码示例来源:origin: PhilJay/MPAndroidChart

@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
    case R.id.viewGithub: {
      Intent i = new Intent(Intent.ACTION_VIEW);
      i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/PerformanceLineChart.java"));
      startActivity(i);
      break;
    }
  }
  return true;
}

代码示例来源:origin: stackoverflow.com

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  MenuInflater inflater = getSupportMenuInflater();
  inflater.inflate(R.menu.main, menu);
  return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
  case R.id.activity_menu_item:
    // Do Activity menu item stuff here
    return true;
  case R.id.fragment_menu_item:
    // Not implemented here
    return false;
  default:
    break;
  }

  return false;
}

代码示例来源:origin: PhilJay/MPAndroidChart

@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
    case R.id.viewGithub: {
      Intent i = new Intent(Intent.ACTION_VIEW);
      i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartPositiveNegative.java"));
      startActivity(i);
      break;
    }
  }
  return true;
}

代码示例来源:origin: stackoverflow.com

@Override
 public boolean onCreateOptionsMenu(Menu menu) {
   MenuInflater inflater = getMenuInflater();
   inflater.inflate(R.menu.actionbarhelpmenu, menu);
   final Menu m = menu;
   final MenuItem item = menu.findItem(R.id.ActionConnection);
   item.getActionView().setOnClickListener(new OnClickListener() {
     @Override
     public void onClick(View v) {   
       m.performIdentifierAction(item.getItemId(), 0);
     }
   });
   return true;
 }

代码示例来源:origin: PhilJay/MPAndroidChart

@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
    case R.id.viewGithub: {
      Intent i = new Intent(Intent.ACTION_VIEW);
      i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/ListViewBarChartActivity.java"));
      startActivity(i);
      break;
    }
  }
  return true;
}

代码示例来源:origin: PhilJay/MPAndroidChart

@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
    case R.id.viewGithub: {
      Intent i = new Intent(Intent.ACTION_VIEW);
      i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/HalfPieChartActivity.java"));
      startActivity(i);
      break;
    }
  }
  return true;
}

代码示例来源:origin: PhilJay/MPAndroidChart

@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
    case R.id.viewGithub: {
      Intent i = new Intent(Intent.ACTION_VIEW);
      i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/LineChartActivityColored.java"));
      startActivity(i);
      break;
    }
  }
  return true;
}

代码示例来源:origin: PhilJay/MPAndroidChart

@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
    case R.id.viewGithub: {
      Intent i = new Intent(Intent.ACTION_VIEW);
      i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/ListViewMultiChartActivity.java"));
      startActivity(i);
      break;
    }
  }
  return true;
}

代码示例来源:origin: PhilJay/MPAndroidChart

@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
    case R.id.viewGithub: {
      Intent i = new Intent(Intent.ACTION_VIEW);
      i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/fragments/SimpleChartDemo.java"));
      startActivity(i);
      break;
    }
  }
  return true;
}

代码示例来源:origin: PhilJay/MPAndroidChart

@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
    case R.id.viewGithub: {
      Intent i = new Intent(Intent.ACTION_VIEW);
      i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/ScrollViewActivity.java"));
      startActivity(i);
      break;
    }
  }
  return true;
}

代码示例来源:origin: stackoverflow.com

@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
  switch (menuItem.getItemId()) {
    case android.R.id.home:
      Intent homeIntent = new Intent(this, HomeActivity.class);
      homeIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
      startActivity(homeIntent);
  }
  return (super.onOptionsItemSelected(menuItem));
}

代码示例来源:origin: stackoverflow.com

@Override
public boolean onOptionsItemSelected(MenuItem item)
{
  switch(item.getItemId())
  {
    case R.id.preferences:
    {
      Intent intent = new Intent();
      intent.setClassName(this, "your.package.MyPreferenceActivity");
      startActivity(intent);
      return true;
    }
  }

  return super.onOptionsItemSelected(item);
}

代码示例来源:origin: stackoverflow.com

@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
    case android.R.id.home:
      // app icon in action bar clicked; go home
      Intent intent = new Intent(this, HomeActivity.class);
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
      startActivity(intent);
      return true;
    default:
      return super.onOptionsItemSelected(item);
  }
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
 public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
   case R.id.settings:
    startActivity(new Intent(this, EditPreferences.class));

    return(true);
  }

  return(super.onOptionsItemSelected(item));
 }
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public boolean onOptionsItemSelected(MenuItem item) {
 if (item.getItemId()==R.id.launch) {
  startActivity(new Intent(this, DropActivity.class)
   .setFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT |
        Intent.FLAG_ACTIVITY_NEW_TASK |
        Intent.FLAG_ACTIVITY_MULTIPLE_TASK));
  return(true);
 }
 return(super.onOptionsItemSelected(item));
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
 public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
   case R.id.settings:
    startActivity(new Intent(this, EditPreferences.class));

    return(true);
  }

  return(super.onOptionsItemSelected(item));
 }
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
 public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
   case R.id.settings:
    startActivity(new Intent(this, EditPreferences.class));

    return(true);
  }

  return(super.onOptionsItemSelected(item));
 }
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
 public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
   case R.id.settings:
    startActivity(new Intent(this, EditPreferences.class));

    return(true);
  }

  return(super.onOptionsItemSelected(item));
 }
}

相关文章