android - 带有警报对话框的代码行为

标签 android android-alertdialog

我只是想了解我的方法是否有一些显示警报对话框的代码,然后是一些其他代码,然后当显示警报对话框并且我没有单击任何按钮时,我的代码会在警报下方吗 dialog.show() 行是等待对话框取消还是直接执行而不等待警报对话框的响应?请帮助我理解这一点。

AlertDialog.Builder builder = new AlertDialog.Builder(ShowLog.this);
builder.setMessage("Do you really want to delete the "+size+" records?")
    .setCancelable(false)
    .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
        //Doing some work          
        }
    })
    .setNegativeButton("No", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();

       }
    });
AlertDialog alert = builder.create();
alert.show();

SomeWork();
Somework1();

我想知道什么时候 SomeWork();将被执行。是在显示警报对话框之后还是在单击警报对话框的是或否之后?

最佳答案

使用 AsyncTask 进行后台处理

关于android - 带有警报对话框的代码行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8246685/

相关文章:

android - 在日期选择器中禁用 future 日期选择

java - Firestore中如何统计一个集合下的文档数?

java - 无法导入 org.apache.commons.io.output.TeeOutputStream

android - 无法在 dialogfragment 中的按钮上获取指针

android - alertDialogue 中按钮的 OnclickListner 出现 NullPointerException

android - 以 getApplication() 作为上下文的对话框抛出 "Unable to add window — token null is not for an application”

android - 如何从 Activity 警报对话框中检索多项检查选择

android - 你能在 Ubuntu 上构建 React Native 应用程序(Android 应用程序)吗?

android - 在搭载 Android 7 的三星 S7 上使用 React Native 时 libjsc.so 中的 native 崩溃

android - removeEventListener 不适用于 Firebase 数据库