Android系列之UI組件----Menu菜單
29 @Override
30 public boolean onOptionsItemSelected(MenuItem item) {
31 // Handle action bar item clicks here. The action bar will
32 // automatically handle clicks on the Home/Up button, so long
33 // as you specify a parent activity in AndroidManifest.xml.
34 switch (item.getItemId()) {
35 case R.id.start:
36 Toast.makeText(this, 開始游戲, Toast.LENGTH_SHORT).show();
37 break;
38 case R.id.over:
39 Toast.makeText(this, 結(jié)束游戲, Toast.LENGTH_SHORT).show();
40 break;
41
42 default:
43 break;
44 }
45 return super.onOptionsItemSelected(item);
46 }
47 }
評論