title: How to create custom Material Dialog
body: <p>I would like to know how to create custom material dialog for my application. Specifically, I need to achieve something like this</p>
  
  <p><a href="https://i.stack.imgur.com/1yO6y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1yO6y.png" alt="Material Dialog"></a></p>
  
  <p>I have been following old method like this way:</p>
  
  <pre><code>final Dialog dialog = new Dialog(context);
  dialog.setContentView(R.layout.custom);
  dialog.setTitle("Sample");
  Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK);
              // if button is clicked, close the custom dialog
              dialogButton.setOnClickListener(new OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      dialog.dismiss();
                  }
              });
  </code></pre>
  
  <p>However, I got null pointer exception while tapping the <code>button</code>. Any tutorial will be also a great help for me.</p>