[android]代码库
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode==KeyEvent.KEYCODE_BACK)
exitdialog();
return super.onKeyDown(keyCode, event);
}
private void exitdialog() {
Dialog dialog=new AlertDialog.Builder(类名.this)
.setTitle("退出程序")
.setMessage("你确认要退出本程序吗?")
.setPositiveButton("确定", new OnClickListener() {
@Override
public void onClick(DialogInterface dialo, int whicutton) {
类名.this.finish();
}
}).setNegativeButton("取消", new OnClickListener() {
@Override
public void onClick(DialogInterface dilg, int whchutton) {
}
}).create();
dialog.show();
}
初级程序员
by: 云代码会员 发表于:2016-10-14 02:43:45 顶(0) | 踩(0) 回复
頂
回复评论