标签:
1 private void exitDialog() { 2 Dialog dialog = new AlertDialog.Builder(this).setIcon(R.drawable.pic_m) 3 .setTitle("程序退出? ").setMessage("您确定要退出本程序吗?") 4 5 .setNegativeButton("取消", new DialogInterface.OnClickListener() { 6 public void onClick(DialogInterface dialog, int which) { 7 } 8 }) 9 .setPositiveButton("确定", new DialogInterface.OnClickListener() { 10 public void onClick(DialogInterface dialog, int which) { 11 MainActivity.this.finish(); 12 } 13 }).create(); 14 15 dialog.show(); 16 } 17 18 public boolean onKeyDown(int keyCode, KeyEvent event) { 19 if (keyCode == KeyEvent.KEYCODE_BACK) { 20 this.exitDialog(); 21 } 22 return false; 23 }
标签:
原文地址:http://www.cnblogs.com/clannad493862452/p/4480568.html