Code example for MenuItem

Methods: setOnMenuItemClickListener

0
 
    @Override 
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
        MenuItem menuItem = menu.add("About");
        menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
			 
			@Override 
			public boolean onMenuItemClick(MenuItem item) {
				showDialog(DIALOG_ABOUT_ID);
				return true; 
			} 
		}); 
        return true; 
    } 
 
    protected Dialog onCreateDialog(int id) {
        Dialog dialog = new Dialog(this);
        switch(id) {
        case DIALOG_ABOUT_ID:
    		dialog.setContentView(R.layout.about_dialog);