首页 > 代码库 > Android 退出提示框 代码

Android 退出提示框 代码

转自:http://hi.baidu.com/ittdt/item/d932cf37f486f886c3cf29ea

new AlertDialog.Builder(MainEngine.context)
    //.setTitle("提示")
    .setMessage("确定要退出游戏吗?")
    .setPositiveButton("确定", new DialogInterface.OnClickListener() {
     @Override
     public void onClick(DialogInterface arg0,
       int arg1) {
      // TODO Auto-generated method stub
      // finish();
      android.os.Process.killProcess(android.os.Process.myPid());
     }
    })
    .setNegativeButton("取消", new DialogInterface.OnClickListener() {
     @Override
     public void onClick(DialogInterface arg0,
       int arg1) {
      // TODO Auto-generated method stub
     }
    }).show();