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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:27:23+00:00 2026-06-05T03:27:23+00:00

I have an activity that has two EditText boxes, one email and one plain

  • 0

I have an activity that has two EditText boxes, one email and one plain text. I want to check that the email box is not empty and also that is matches an email pattern before allowing the user to move on. The pattern matcher part works, but the empty string part doesn’t.

I validate as the user enters data, and then set the two buttons to the be clickable or not according to whether the email is correct. However, if the box is empty, it allows the user to press the button when it shouldn’t. When there is text in the box, it does the correct thing of only letting the user press the button when the email pattern has been matched.

My after text changed method:

        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub
            String enteredEmail = email.getText().toString();

            if (validateEmail(enteredEmail) == true) {
                image1.setImageResource(R.drawable.greentick);
                play.setClickable(true);
                play.setFocusable(true);
                existingUser.setClickable(true);
                existingUser.setFocusable(true);
            }

            else {
                System.out.println("Invalid");
                image1.setImageResource(R.drawable.redcross);
                play.setClickable(false);
                play.setFocusable(false);
                existingUser.setClickable(false);
                existingUser.setFocusable(false);
            }
        }

And my validateEmail() method:

public boolean validateEmail(String email) {

    boolean validated = false;
    if (android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches() && (! email.equals("")) ) {
        validated = true;           
    }

    else {
        validated = false;
    }   
    return validated;
}
  • 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-05T03:27:24+00:00Added an answer on June 5, 2026 at 3:27 am

    TextChanged won’t fire if the user hasn’t entered anything, as the text hasn’t changed… You should disable the button by default.

    Have you tried debugging, as this should have shown you the event isn’t firing.

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

Sidebar

Related Questions

I have an activity that has two layouts one in the folder layout and
I have an activity that has two tabs and a list view in each.
I have an Android application that contains two Activities . Activity A has a
I have a mapView activity that has a LocationListener registered to check for a
I have two classes that extend the activity class. Each class has it's own
I have an activity that has a checkbox, then under it is a list
I have an android app that has mutliple activities The first main activity starts
I have an Activity class which has an attribute that references an AsyncTask instance
Assume that we have 3 different activities. Each activity has its own XML file
I have an activity that when created contains an EditText but if you click

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.