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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:46:26+00:00 2026-05-27T17:46:26+00:00

I have a simple Activity with 3 EditText fields. User, Pass, Confirmation After typing

  • 0

I have a simple Activity with 3 EditText fields.

User, Pass, Confirmation

After typing something in the User field and the person clicks next on the keyboard, I have a setOnFocusChangeListener on there that will validate the input. If the validation fails a Dialog opens with a message and an OK button.

After the Dialog is closed I tried a requestFocus on my User EditText in many variations, by releasing it on Pass, by trying to release on User again, by requesting than clearing and requesting again but when I click on another field the softkeyboard won’t open again or I end up with two EditText fields with the blinking cursor.

Any ideas?

  • 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-27T17:46:27+00:00Added an answer on May 27, 2026 at 5:46 pm

    I suggest validating the user’s input with a TextWatcher:

    EditText textbox = new EditText(context);
    textbox.addTextChangedListener(new TextWatcher() {
                @Override
                public void afterTextChanged(Editable s) {
                    // Your validation code goes here
                }
    
                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {
                }
    
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                }
            });
    

    Only handle validation in the afterTextChanged method, don’t touch the other two, as advised in the documentation. However afterTextChanged get’s fired, every time the input changes, so if the user enters the word “hello” this method get’s called when h is entered, then again when e is entered and so on… Furthermore, if you modify the edittext value in afterTextChanged, the method get’s called too.

    An alternative is to validate the user input when the EditText loses focus. For this purpose you could use:

        textbox.setOnFocusChangeListener(new OnFocusChangeListener() {
    
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                // Your validation code goes here
            }
        });
    

    However beware, that some widgets might not grab focus, so your Edittext never loses it (had that with Buttons for instance).

    Furthermore the EditText offers a setError method, which marks the edittext with a red error mark and shows the text passed to setError to the user (the text can be set by you when calling setError(“Your error message”)).

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

Sidebar

Related Questions

friends, i have a EditText on simple activity with a button. when every i
I have a simple activity with only one edittext which was set to http://
I have a relatively simple layout that contains an EditText . The activity itself
I have an Activity that consists of a large scrollview (that contains EditText fields)
I have an simple EditText inside an Activity and I want to create a
I have a simple activity in android where I'm doing something like: givepassw =
So I have a very simple android activity that starts a timer when you
This seems like a simple problem: I have a WF4 activity that guides the
I have simple win service, that executes few tasks periodically. How should I pass
I have got a main extending adapter which adds rows when user clicks on

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.