Android点击返回键back时弹出对话框Dialog
2014-06-22 15:53
519 查看
public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { ExitDialog(MainActivity.this).show(); return true; } return super.onKeyDown(keyCode, event); }
private Dialog ExitDialog(Context context) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setIcon(R.drawable.icon); builder.setTitle("弹出对话框"); builder.setMessage("确定要××××吗,O(∩_∩)O哈哈~"); builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { //××××操作代码 } }); builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); return builder.create(); }
相关文章推荐
- Android点击返回键back时弹出对话框Dialog
- dialog弹出,点击back按键无法返回问题解决
- Android中点击返回键时候,弹出两个Dialog的问题
- 弹出dialog后不可点击back返回,用广播退出所有activity
- android 实现点击输入框弹出日期选择对话框(DatePickerDialog)
- Android 中 弹出 Dialog 后监听 Back键 点击事件
- Android 监听返回键,弹出确认退出对话框
- android-点击button弹出对话框
- android在Service中弹出Dialog对话框,即全局性对话框
- Android: 创建一个AlertDialog对话框,必须按确定或取消按钮才能关闭对话框,禁止按[返回键]或[搜索键]关闭
- android EditText实现点击弹出dialog
- Android 如何监听返回键,弹出一个退出对话框
- android在Service中弹出Dialog对话框,即全局性对话框
- Air for Android开发中使用Back键弹出是否退出对话框
- Android菜鸟笔记-Service中弹出对话框,即全局性质Dialog不依赖于Activity
- Android 如何监听返回键,弹出一个退出对话框
- Android 弹出对话框Dialog
- android 点击文本框弹出日期对话框
- android弹出对话框时对返回键的监听细节
- Android: 创建一个AlertDialog对话框,必须按确定或取消按钮才能关闭对话框,禁止按[返回键]或[搜索键]关闭