Dialog dialog = new Dialog(context); dialog.setContentView(R.layout.custom_dialog_box); dialog.setTitle("Confirm Purchase"); Button confirmButton = dialog.findViewById(R.id.confirm_button); confirmButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // perform purchase dialog.dismiss(); } }); Button cancelButton = dialog.findViewById(R.id.cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show();
ProgressDialog progressDialog = new ProgressDialog(context); progressDialog.setTitle("Downloading File..."); progressDialog.setMessage("Please Wait..."); progressDialog.setIndeterminate(true); progressDialog.setCancelable(false); progressDialog.show(); // perform download progressDialog.dismiss();The package library for `android.app.Dialog` is `android.app`.