我如何在 AlertDialog 上显示 surfaceview

How can i show surfaceview on AlertDialog

我正在尝试在 AlertDialog 上实施 SurfaceView,但出现此错误

error: incompatible types: <anonymous OnClickListener> cannot be converted to Callback

这是我试过的

 LayoutInflater inflater = getLayoutInflater();
 View alertLayout = inflater.inflate(R.layout.popupdialog, null);
 SurfaceView dialogsurface=(SurfaceView)alertLayout.findViewById(R.id.dialogcamerapreview);
 surfaceHolder = dialogsurface.getHolder();
 surfaceHolder.addCallback(this);
 surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
 AlertDialog.Builder alert = new AlertDialog.Builder(mContext);
 alert.setTitle("Info");
 alert.setView(alertLayout);
 alert.setCancelable(false);
 alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
                Toast.makeText(getBaseContext(), "Cancel clicked", Toast.LENGTH_SHORT).show();
               }
         });

         alert.setPositiveButton("Done", new DialogInterface.OnClickListener() { 
         @Override
         public void onClick(DialogInterface dialog, int which) {
                 Toast.makeText(LoginActivity.this, "Photo captured..", Toast.LENGTH_SHORT).show();    
         }
   });
  AlertDialog dialog = alert.create();
  dialog.show();

任何帮助将不胜感激

使用这个

surfaceHolder.addCallback(LoginActivity.this);
Toast.makeText(LoginActivity.this, "Cancel clicked", Toast.LENGTH_SHORT).show();

而不是这个

surfaceHolder.addCallback(this);
Toast.makeText(getBaseContext(), "Cancel clicked", Toast.LENGTH_SHORT).show();