MENU菜单的设计

public boolean onMenuItemSelected(int featureId, MenuItem item) {
		switch (item.getItemId()) {
		case Menu.FIRST + 1:
			// 这里就是设置弹出对话框的地方
			new AlertDialog.Builder(YcMusicPlay.this)
					.setIcon(R.drawable.dialog_information).setTitle("关于")
					.setMessage(R.string.about).setPositiveButton("确定", null)
					.show();
			break;

		case Menu.FIRST + 2:
			new AlertDialog.Builder(YcMusicPlay.this)
					.setIcon(R.drawable.dialog_information)
					.setTitle("提示")
					.setMessage("你确定要退出Yc音乐吗?")
					.setPositiveButton("确定",
							new DialogInterface.OnClickListener() {

								public void onClick(DialogInterface dialog,
										int which) {
									/* 在这里设计当对话框按钮单击之后要运行的事件 */
									stopService(new Intent(YcMusicPlay.this,
											YcMusicService.class));
									System.exit(0);
								}
							}).setNegativeButton("取消", null).show();

			break;
		}
		return false;
	}

你可能感兴趣的:(MENU菜单的设计)