一个简单的menu菜单示例:
public class MenuDemo extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.add(0,0,0,"老婆"); menu.add(0,1,0,"老公"); menu.add(0,2,0,"菜单一"); menu.add(0,3,0,"菜单二"); menu.add(0,4,0,"菜单三"); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { super.onOptionsItemSelected(item); TextView view = (TextView) findViewById(R.id.text_view); switch (item.getItemId()) { case 0: view.setText("这是"+item.getTitle()); break; case 1: view.setText("这是"+item.getTitle()); break; default: view.setText("这是老婆的菜单,嘿嘿。。。"); break; } return false; } @Override public boolean onPrepareOptionsMenu(Menu menu) { return super.onPrepareOptionsMenu(menu); } }