android custom Dialog with Button onClick event

parameter initilize

  Dialog dialog;

You use this where You want to use

dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.custom_dialog);
    dialog.show();


TextView tv_message = (TextView) dialog .findViewById(R.id.textViewMessage);

tv_message.setText(message);

Button bt_yes = (Button)dialog.findViewById(R.id.buttonYes);
   Button bt_no = (Button)dialog.findViewById(R.id.buttonNo);

bt_yes.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        CheckYes();
    }
});
bt_no.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        dialog.dismiss();
    }
});

Tags:

Android

Dialog