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 7522965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:39:43+00:00 2026-05-30T02:39:43+00:00

I am working with AlertDialog for user login to an application.I have displayed two

  • 0

I am working with AlertDialog for user login to an application.I have displayed two edit views for enter user name and password and also I have used positive button and negative button on alert dialog.When the user entered invalid user name or password then click on ok i am displaying a text on same alert dialog with TexView but the alert dialog is closing.How can i stay with alert dialog till user enter valid details on edit text feilds?

i have implemented code for get the alert as follows:

    AlertDialog.Builder alert = new AlertDialog.Builder(this);
    alert.setTitle("Login here");
    alert.setView(table);
    alert.setPositiveButton("Login", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int whichButton) {

        objLogin.setLoginUsrName(userNameText.getText().toString());
        objLogin.setLoginPassword(passwordText.getText().toString());

        if(objLogin.userValid())
        {

          //getting next screen


        }
        else{
            invalid.setText("Invalid user name or password");
            invalid.setTextColor(Color.RED);

            //diaplay same alert here with invalid text

        }

      }
    });

    alert.setNegativeButton("Register", new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int whichButton) {

                 //get register screen code here
      }
    });

    alert.show();              

How can i show the alert till user entered valid details?

  • 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-05-30T02:39:44+00:00Added an answer on May 30, 2026 at 2:39 am

    I think the problem is the positiveButton and negativeButton from the AlertDialog class. AlertDialog closes after pressing these. You might have better luck with a Dialog Builder instead of an AlertDialog, but I haven’t tested that.

    Another fix:

    Try adding two Android widgets to your ‘table’ layout, and setting an onclicklistener on them. Do this instead of the two default positive/negative buttons from the AlertDialog. This approach will also allow you to modify the placement and style of the buttons.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have application working with SQLite DB(table with two rows) I need to recieve
I have one AlertDialog which is working fine.I have set some background images to
can someone help me with this? I have an AlertDialog box and its working
I have a little issue with AlertDialog on my application. I'm showing an AlertDialog
I have an AlertDialog.Builder displaying on an application. When I rotate the screen, I
I'm working with a RadioGroup . I have used the following code to implement
I've been working on this application but have come across a problem that I
Working on a project at the moment and we have to implement soft deletion
I have created a custom alertdialog by the following code: AlertDialog.Builder builder; AlertDialog alertDialog;
My Android app has two Spinners (dropdown menus) working fine. However, now I've added

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.