0

Below email input there is 2 text view buttons (cancel, and recover)

Hi guys I searched through other titles relating to white on white text but they do not help me as I encounter this issue when forgot password has been clicked. As you can see all other fields within the dialogue box seem to appear as they should, however my cancel, and recover buttons are unseen until clicked and a very light grey box forms around the buttons.

I have tried to use setTitle(androidcolor.R.black)inside the code but it didnt work haha. I am learning slowly and this may very well be an easy fix but it evades me for now.

This is the code I have run with it hopefully it helps someone help me or at least point me to the right place :)

 private void showRecoverPasswordDialog() {
    //AlertDialog
    AlertDialog.Builder builder =  new AlertDialog.Builder(this);
    builder.setTitle("Recover Password");

    //Set Layout to Linear Layout
    LinearLayout linearLayout = new LinearLayout(this);

    //Views to set in Dialog
    final EditText emailET = new EditText(this);
    emailET.setHint("Email");
    emailET.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);

    emailET.setMinEms(16);

    linearLayout.addView(emailET);
    linearLayout.setPadding(10,10,10,10);

    builder.setView(linearLayout);

    //Button to Recover
    builder.setPositiveButton("Recover", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            //Input Email for Recovery
            String email = emailET.getText().toString().trim();
            beginRecovery(email);
        }
    });
    //Button to Cancel
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            //Dismiss Dialog
            dialog.dismiss();
        }
    });

    //Show Dialog
    builder.create().show();

}

private void beginRecovery(String email) {
    //Show progress dialog
    progress_Dialog.setMessage("Recovery Email sending...");
    progress_Dialog.show();
    mAuth.sendPasswordResetEmail(email).addOnCompleteListener(new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull Task<Void> task) {
            progress_Dialog.dismiss();
            if(task.isSuccessful()){
                Toast.makeText(LoginActivity.this, "Recovery Email has been sent", Toast.LENGTH_SHORT).show();
            }
            else{
                Toast.makeText(LoginActivity.this, "Recovery Email failed to send ", Toast.LENGTH_SHORT).show();
            }
        }
    }).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {
            progress_Dialog.dismiss();
            //Get and Show proper Error Message
            Toast.makeText(LoginActivity.this, ""+e.getMessage(), Toast.LENGTH_SHORT).show();
        }
    });
}

private void loginUser(String email, String passw) {
    //Show progress dialog
    progress_Dialog.setMessage("Logging in...");
    progress_Dialog.show();
    mAuth.signInWithEmailAndPassword(email, passw)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()) {
                        //Dismiss progress dialog
                        progress_Dialog.dismiss();
                        // Sign in success, update UI with the signed-in user's information
                        FirebaseUser user = mAuth.getCurrentUser();
                        //User is logged in, start Login Activity
                        startActivity(new Intent(LoginActivity.this, ProfileActivity.class));
                        finish();
                    } else {
                        //Dismiss progress dialog
                        progress_Dialog.dismiss();
                        // If sign in fails, display a message to the user.
                        Toast.makeText(LoginActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }
                }
            }).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {
            //Dismiss progress dialog
            progress_Dialog.dismiss();
            //Get and show an Error Message
            Toast.makeText(LoginActivity.this, ""+e.getMessage(), Toast.LENGTH_SHORT).show();
        }
    });

}
  • where is the xml for the dialog? – Jose Antonio Feb 28 '20 at 00:53
  • 1
    It doesn't seem like he's using any custom XML layout, he's just dynamically populating the linear layout for the dialog contents, then relying on the AlertBuilder to draw the positive/negative buttons. – pushasha Feb 28 '20 at 00:55
  • so, it might be the error, I usually create a regular dialog to populate it, hardcoding is not funny at all. – Jose Antonio Feb 28 '20 at 00:58
  • 2
    best solution is to use a specific theme for the dialog, see this answer: https://stackoverflow.com/a/42373688/4409409 – Daniel Nugent Feb 28 '20 at 01:00
  • Hi guys thank you for all replies...whether or not this is the correct way or if it will have a negative effect down the track I found a very straight forward no brainwork needed solution. I was trying to follow the thread @DanielNugent had suggested but was having trouble still...anyway I simply changed the accent colour in my app theme in styles to desired colour and voila...simple but as I said earlier im yet to discover if it will have an effect later – Kono Harris Feb 28 '20 at 01:58

0 Answers0