title: How to create a Custom Dialog box in android?
body: <p>I want to create a custom dialog box like below </p>
  
  <p><img src="https://i.stack.imgur.com/zu0ss.png" alt="enter image description here"></p>
  
  <p>I have tried the following things.</p>
  
  <ol>
  <li><p>I created a subclass of <strong>AlertDialog.Builder</strong> and used a custom Title and Custom Content View and used that but the result was not as expected.</p></li>
  <li><p>Another attempt was to subclass <strong>DialogFragment</strong> and customize the dialog inside onCreateDialog that but result was not as expected.</p></li>
  <li><p>Then I tried using a plain <strong>Dialog</strong> class. The result was not as expected.</p></li>
  </ol>
  
  <p>In all three cases, the problem is when I overlook the title view the size of the dialog is not as expected and when I use Title view the result is there is a thick border around the content view (which really looks bad). Now I have two questions in my mind...</p>
  
  <ol>
  <li><p>How can I achieve that? As I have already tried so many things, a direct answer will be more appreciated.</p></li>
  <li><p>What is the best way to show an error or alert dialog in an android app?</p></li>
  </ol>
  
  <p><strong>EDIT</strong>
  <a href="http://developer.android.com/guide/topics/ui/dialogs.html">Android Developer Documentation</a> recommends that we should use either DialogFragments or Dialogs for showing Error / Alert Messages to the user. However at one point they say ...</p>
  
  <blockquote>
    <p>Tip: If you want a custom dialog, you can instead display an Activity as a dialog instead of using the Dialog APIs. Simply create an activity and set its theme to Theme.Holo.Dialog in the  manifest element.</p>
  </blockquote>
  
  <p><strong>What is the meaning of that? Isn't it too much to use an Activity just for showing an error message???</strong> </p>