Reputation: 99
I'm trying to implement SurfaceView
on AlertDialog
but I am getting this error
error: incompatible types: <anonymous OnClickListener> cannot be converted to Callback
this is what I tried
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();
Any help would be highly appreciated
Upvotes: 0
Views: 386
Reputation: 69699
Use this
surfaceHolder.addCallback(LoginActivity.this);
Toast.makeText(LoginActivity.this, "Cancel clicked", Toast.LENGTH_SHORT).show();
Instead of this
surfaceHolder.addCallback(this);
Toast.makeText(getBaseContext(), "Cancel clicked", Toast.LENGTH_SHORT).show();
Upvotes: 1