Check out example codes for "code to close dialog containg layout". It will help you in understanding the concepts better.

Code Example 1

AlertDialog.Builder builder = new AlertDialog.Builder(this);

    LayoutInflater inflater = getLayoutInflater();
    View dialogView = inflater.inflate(R.layout.brush_opts_dialog,null);


    closeBtn = (Button)dialogView.findViewById(;

   final AlertDialog dialog = builder.create();

    closeBtn .setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

Learn ReactJs, React Native from