Android: onCreateOptionsMenu() item action

后端 未结 4 2125
南旧
南旧 2021-02-06 23:49

I have a menu created through:

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(\"Email\");

    return super.onCreateOptionsMenu(menu)         


        
4条回答
  •  借酒劲吻你
    2021-02-07 00:50

    From Android developer guide

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
    case R.id.new_game:
        newGame();
        return true;
    case R.id.help:
        showHelp();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
    }
    

提交回复
热议问题