标签:
@Override public boolean onCreateOptionsMenu(Menu menu) { menu.add(0,0,0,"关于"); menu.add(0,1,1,"退出"); return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch(item.getItemId()){ case 1: AlertDialog.Builder builder=new AlertDialog.Builder(this).setTitle("退出").setMessage("确定要退出吗?").setPositiveButton("取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { alertDialog.dismiss(); } }).setNegativeButton("确定",new DialogInterface.OnClickListener(){ @Override public void onClick(DialogInterface dialog, int which) { finish(); } }).setCancelable(false); alertDialog=builder.create(); alertDialog.show(); break; } return super.onOptionsItemSelected(item); }
标签:
原文地址:http://www.cnblogs.com/zqxLonely/p/5549200.html