I want to create a custom dialog box like below
I have tried the foll
Create Custom Alert Dialog
cumstomDialog.xml
Show your custom dialog on your activity:
public void showDialog(String title, String des, int icon) {
final Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.custom_dialog);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
Button cancelBTN = dialog.findViewById(R.id.cancelBTN);
Button acceptBTN = dialog.findViewById(R.id.acceptBtn);
TextView tvTitle = dialog.findViewById(R.id.title);
TextView tvDescription = dialog.findViewById(R.id.description);
ImageView ivIcon = dialog.findViewById(R.id.icon);
tvTitle.setText(title);
tvDescription.setText(des);
ivIcon.setImageResource(icon);
cancelBTN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
acceptBTN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
dialog.show();
}
Call like this:
showDialog("Title", "Message", R.drawable.warning);