我想为我的应用程序创建模式对话框.
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中创建模态对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!