title: AlertDialog dialog.dismiss(), dialog.close() not working
body: <p>I have to click twice in the button (any: positive, neutral, and negative) for it to dismiss the AlertDialog.</p>
  
  <pre><code>import android.annotation.SuppressLint
  import android.os.Bundle
  import android.support.design.widget.Snackbar
  import android.support.v7.app.AlertDialog
  import android.support.v7.app.AppCompatActivity
  import android.view.KeyEvent
  import android.view.View
  import com.example.said.puntodeventa.R.layout.layout_addproduct
  
  class someClass : AppCompatActivity() {
  
  @SuppressLint("StringFormatInvalid")
  private fun someDialog(){
  AlertDialog.Builder(this).apply {
                  setTitle("title")
                  setMessage("message")
                  setNegativeButton("No"){ dialog, which -&gt;
                      anEditText.text.clear()
                      anEditText.requestFocus()
                      dialog.cancel()
                      dialog.dismiss()
                  }
                  setNeutralButton("Neutral"){ dialog, which -&gt;
                      someEditText.text.clear()
                      someEditText.requestFocus()
                      dialog.cancel()
                      dialog.dismiss()
                  }
                  setPositiveButton("Yes") { dialog, which -&gt;
                      addProduct()
                      dialog.cancel()
                      dialog.dismiss()
                  }
                  create()
                  show()
              }
          }
  
  private fun addProduct(){
          //some code working properly
      }
  }
  </code></pre>
  
  <p><code>addProduct()</code> and <code>.text.clear()</code> work perfectly, but the AlertDialog does not close the first time I click on it.</p>
  
  <p>I've tried using only with <code>dialog.cancel()</code>, <code>dialog.dismiss()</code> separately and nothing seems to work, like the code is not there.</p>
  
  <p>I've also tried import <code>android.app.AlertDialog</code> with the same results.</p>
  
  <p>This is the red text in the log when I click any of the buttons, it does not matter if it is the first time (when the AlertDialog does not close) or the second (when it actually closes).</p>
  
  <pre><code>05-19 16:42:34.543 24647-24647/com.example.name.appdemo E/ViewRootImpl: sendUserActionEvent() mView == null
  </code></pre>
  
  <p>Thanks</p>