Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8615215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:19:12+00:00 2026-06-12T05:19:12+00:00

I am trying to make a password prompt, when user entered a wrong password,

  • 0

I am trying to make a password prompt, when user entered a wrong password, it will show a dialog asking to “cancel” or “retry” and when the user clicks on “retry”, it will display the password prompt again.

Below are images to illustrate what I meant

enter image description here

enter image description here

This is how I have done it

 /** RETRIEVE VIEW FROM DIALOGPROMPT.XML AND SET VIEW AS AN ALERTDIALOG BUILDER **/
                LayoutInflater li = LayoutInflater.from(context);
                View promptsView = li.inflate(R.layout.searchprompt, null);
                AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
                alertDialogBuilder.setView(promptsView);

                final EditText userInput = (EditText) promptsView
                        .findViewById(R.id.user_input);


                // set dialog message
                alertDialogBuilder
                    .setCancelable(false)
                    .setNegativeButton("Go",
                      new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog,int id) {
                            /** DO THE METHOD HERE WHEN PROCEED IS CLICKED*/
                            String user_text = (userInput.getText()).toString();

                            /** CHECK FOR USER'S INPUT **/
                            if (user_text.equals("oeg"))
                            {
                                Log.d(user_text, "HELLO THIS IS THE MESSAGE CAUGHT :)");
                                Search_Tips(user_text); 

                            }
                            else{
                                Log.d(user_text,"string is empty");
                                String message = "The password you have entered is incorrect." + " \n" + "Please try again";
                                AlertDialog.Builder builder = new AlertDialog.Builder(context);
                                builder.setTitle("Error");
                                builder.setMessage(message);
                                builder.setPositiveButton("Cancel", null);
                                builder.setNegativeButton("Retry", null);
                                builder.create().show();

                            }
                            }
                      })
                    .setPositiveButton("Cancel",
                      new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog,int id) {
                        dialog.cancel();
                        }
                      });

                // create alert dialog
                AlertDialog alertDialog = alertDialogBuilder.create();

                // show it
                alertDialog.show();

            }
        });

Does anyone know how to do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:19:13+00:00Added an answer on June 12, 2026 at 5:19 am

    I have solved my own problem. I made a method for my alert dialog and then when I click on “retry”, i will call the method again. 🙂

    public void showDialog()
    {
    
        LayoutInflater li = LayoutInflater.from(context);
        View promptsView = li.inflate(R.layout.searchprompt, null);
        final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
        alertDialogBuilder.setView(promptsView);
    
        final EditText userInput = (EditText) promptsView
                .findViewById(R.id.user_input);
    
    
        // set dialog message
        alertDialogBuilder
            .setCancelable(false)
            .setNegativeButton("Go",
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog,int id) {
                    /** DO THE METHOD HERE WHEN PROCEED IS CLICKED*/
                    String user_text = (userInput.getText()).toString();
    
                    /** CHECK FOR USER'S INPUT **/
                    if (user_text.equals("oeg"))
                    {
                        Log.d(user_text, "HELLO THIS IS THE MESSAGE CAUGHT :)");
                        Search_Tips(user_text); 
    
                    }
                    else{
                        Log.d(user_text,"string is empty");
                        String message = "The password you have entered is incorrect." + " \n \n" + "Please try again!";
                        AlertDialog.Builder builder = new AlertDialog.Builder(context);
                        builder.setTitle("Error");
                        builder.setMessage(message);
                        builder.setPositiveButton("Cancel", null);
                        builder.setNegativeButton("Retry", new DialogInterface.OnClickListener() {
                            @Override
                           public void onClick(DialogInterface dialog, int id) {
                                showDialog();
                           }
                       });
                        builder.create().show();
    
                    }
                    }
              })
            .setPositiveButton("Cancel",
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog,int id) {
                dialog.dismiss();
                }
    
              }
    
            );
    
        // create alert dialog
        AlertDialog alertDialog = alertDialogBuilder.create();
    
        // show it
        alertDialog.show();
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make an iPhone App in which i will make user
I'm trying to make a basic, plain-text password login and database user for a
I am trying to make buttons only visible when a password is entered correctly.
I'm trying to make a password protected project in Visual Studio 2010. Is there
I'm working on a password reset function and trying to check to make sure
I'm trying make a login window where a user is prompted to enter their
I'm trying to make a simple username/password authentication in a Spring Security web app.
I'm trying to make a small username and password input box. I would like
I am trying to make a password retrieval system on my site, and I
I'm trying to make a password field for a webpage. So far I have:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.