title: How to dismiss android alert dialog itself via setOnEditorActionListener?
body: <p>There is an alert dialog which contains a password <code>EditText</code> and I'm trying to perform the action which is the same as pressing positive button after the keyboard RETURN button is pressed.</p>
  
  <p>In my MainActivity:</p>
  
  <pre><code>fun enterPwd() {
      val builder = android.app.AlertDialog.Builder(this)
      val password = EditText(this)
  
      // some layout attributes about password are omitted
  
      password.imeOptions = EditorInfo.IME_ACTION_GO
      password.setOnEditorActionListener({
          if(id == EditorInfo.IME_ACTION_GO) { v, id, event -&gt;
              doSomthingFunction()
          }
          false
      }) 
      builder.setView(password).setMessage("message")
                  .setPositiveButton("confirm", { doSomethingFunction() })
                  .setNegativeButton("cancel", { dialog, i -&gt; }).show()
  }
  </code></pre>
  
  <p>In the latter doSomethingFunction() in <code>setPositiveButton</code>, the builder would dismiss automatically after the button is pressed. However in the previous one, the dialog is still there. I had tried to pass <code>dialog = builder.show()</code> and then dismiss by <code>dialog.dismiss()</code> right after <code>doSomethingFunction()</code> in the <code>setOnEditorActionListener</code> (appended as following) but it had no effect. How do I dismiss this dialog after the return key is pressed?</p>
  
  <pre><code>val dialog = builder.show()
  password.setOnEditorActionListener({
      if(id == EditorInfo.IME_ACTION_GO) { v, id, event -&gt;
          doSomthingFunction()
          dialog.dismiss()
      }
      false
  }) 
  </code></pre>