首页 > 解决方案 > AlertDialog.Builder 重置密码按钮不起作用.Android Studio

问题描述

我正在尝试创建 AlertDialogBox 以使用按钮重置密码。但是按钮不起作用。

    reset_pwd.setOnClickListener(v -> {

        EditText resetPassword = new EditText(v.getContext());

        AlertDialog.Builder reset_pwd = new AlertDialog.Builder(v.getContext());
        reset_pwd.setTitle("Reset Password");
        reset_pwd.setMessage("Enter new password > 6 characters long numeric only.");
        reset_pwd.setView(resetPassword);

        reset_pwd.setPositiveButton("Yes", (dialog, which) -> {
            String newPassword = resetPassword.getText().toString();
            user.updatePassword(newPassword).addOnSuccessListener(new OnSuccessListener<Void>() {
                @Override
                public void onSuccess(Void aVoid) {
                    Toast.makeText(MyAccountActivity.this, "Password Reset Successfully.", Toast.LENGTH_SHORT).show();
                }
            }).addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    Toast.makeText(MyAccountActivity.this,"Password Reset Failed", Toast.LENGTH_SHORT).show();
                }
            });
        });

        reset_pwd.setNegativeButton("No", (dialog, which) -> {

        });
    });

标签: androidandroid-studioreset-password

解决方案


推荐阅读