How to create modal dialog box in android(如何在android中创建模态对话框)
问题描述
我想为我的应用程序创建模式对话框.
i want create modal dialog box for my application.
所以当模态对话框打开时,其他活动被阻止.没有像按下后退按钮或按下主页按钮那样完成任何事件.
so when modal dialog box open the other activities are blocked. no event are done like back button press or home button press.
并在该对话框中放置两个选项按钮取消并确定.
and put two option button in that dialog box cancel and ok.
谢谢...
推荐答案
Android中有很多种Dialogs.请查看 对话框.我猜你正在寻找类似 AlertDialog 的东西.这是如何在 BackPress 按钮上实现的示例.
There are many kind of Dialogs in Android. Please take a look at Dialogs. I guess what you are looking for is something like AlertDialog . This is the example of how you can implement on BackPress button.
@Override
public void onBackPressed() {
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Do you want to logout?");
// alert.setMessage("Message");
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
//Your action here
}
});
alert.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
});
alert.show();
}
这篇关于如何在android中创建模态对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在android中创建模态对话框
- UITextView 内容插图 2022-01-01
- 如何在 iPhone 模拟器中重置 NSUserDefaults 数据? 2022-01-01
- 在 Iphone SDK 的导航栏上添加多个按钮 2022-01-01
- SetOnItemSelectedListener上的微调程序错误 2022-01-01
- GPS状态的广播接收器? 2022-01-01
- 类似于 Mail.app 的 iPad 模态视图控制器? 2022-01-01
- Xcode 7.3 中带有 UILabel 的 UIStackView 2022-01-01
- URL编码Swift iOS 2022-01-01
- 使用自动布局向 UIScrollView 添加动态大小的视图 2022-01-01
- 网上有没有好的 UIScrollView 教程? 2022-01-01
