相关疑难解决方法(0)

如何解雇AlertDialog.Builder?

在下面的代码中,如何关闭警告框?我不想导致内存泄漏.我在alertDialog上尝试了.dismiss(),但是没有用......谢谢

// User pressed the stop button
public void StopMsg_button_action(View view){
    final EditText password_input = new EditText(this); // create an text input field
    password_input.setHint("Enter Password"); // put a hint in it
    password_input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); // change it to password type

    AlertDialog.Builder alertDialog = new Builder(this); // create an alert box
    alertDialog.setTitle("Enter Password"); // set the title
    alertDialog.setView(password_input);  // insert the password text field in the alert box
    alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { // define the 'OK' button
        public void onClick(DialogInterface dialog, …
Run Code Online (Sandbox Code Playgroud)

memory alert android dialog dismiss

29
推荐指数
5
解决办法
6万
查看次数

标签 统计

alert ×1

android ×1

dialog ×1

dismiss ×1

memory ×1