方法一:直接在Activity中添加
使用menu.add(groupId, itemId, order, title)的方法添加menu的item,在实现事件时只需使用itemId的值作判断。
方法二:在res/menu/main.xml中添加item。
在xml中添加item方便管理。但要注意,在实现事件时item.getItemId是int类型,可以用R.id.xxx作判断。
方法一:直接在Activity中添加
使用menu.add(groupId, itemId, order, title)的方法添加menu的item,在实现事件时只需使用itemId的值作判断。
方法二:在res/menu/main.xml中添加item。
在xml中添加item方便管理。但要注意,在实现事件时item.getItemId是int类型,可以用R.id.xxx作判断。