菜单的添加

public boolean onCreateOptionsMenu(Menu menu)  {      super.onCreateOptionsMenu(menu);      menu.add(0, 1, 0, "xia");      menu.add(0, 2, 1, "gengj");      menu.add(0, 3, 2, "jia");      menu.add(1, 1, 1, "jie1");      menu.add(1, 2, 2, "dfs1");      return true;  }xingy

子菜单的添加

SubMenu subMenu = menu.addSubMenu(base, base+1, Menu.NONE, "Submenu");subMenu.add(base, base + 2, base + 2, "sub item1");subMenu.add(base, base + 3, base + 3, "sub item2");

响应菜单:

方法一:

public boolean onOptionsItemSelected(MenuItem item) {    // TODO Auto-generated method stub    switch(item.getItemId())    {        ......        return true;    }    return super.onOptionsItemSelected(item);}

方法二:

通过监听器

见《精通Android》P167