Android AlertDialog.setButton使我的应用程序崩溃

Android AlertDialog.setButton使我的应用程序崩溃,android,Android,正如标题所说,当我在警报对话框中设置.setButton时,我的应用程序崩溃。 问题是什么?我应该如何解决 button_fs = (Button) findViewById(R.id.button_fs); final AlertDialog adfs = new AlertDialog.Builder(this).create(); button_fs.setOnClickListener(new OnClickListener() { @Override

正如标题所说,当我在警报对话框中设置.setButton时,我的应用程序崩溃。 问题是什么?我应该如何解决

button_fs = (Button) findViewById(R.id.button_fs);
    final AlertDialog adfs = new AlertDialog.Builder(this).create();
    button_fs.setOnClickListener(new OnClickListener() {
        @Override
            public void onClick(View view) {
            adfs.setTitle("Meraxes");
            adfs.setMessage("What would you like to do?");
            adfs.setButton(1, "OK", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Toast.makeText(getApplicationContext(), "Aww yiss", Toast.LENGTH_SHORT).show();
                }
            });
            adfs.setButton(2, "cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Toast.makeText(getApplicationContext(), "you have pressed cancel", Toast.LENGTH_SHORT).show();
                }
            });
            adfs.show();
        }
    });

例外情况是什么?
setButton()
。。。你不是说
setPositiveButton()
setNegativeButton()
,而是说,我刚发完这篇文章就找到了答案。顺便说一句,感谢您的快速响应。我在adfs.setButton(1,“OK”,新的DialogInterface.OnClickListener()中使用了“DialogInterface.BUTTON_POSITIVE”而不是“1”)