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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:38:13+00:00 2026-06-08T20:38:13+00:00

I have 6 EditText fields in an xml.. on Button click I need to

  • 0

I have 6 EditText fields in an xml.. on Button click I need to validate whether all EditText have values or it is empty.
Currently I am check each EditText one by one.. How can I check all at once.

the Code

private Button BtnSave;
 EditText ev_last_name,ev_first_name,ev_email,ev_password,ev_confirm_password,ev_phone;
 String last_name,first_name,email,password,confirm_password,phone;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.signup);
    BtnSave=(Button) findViewById(R.id.BtnSave);
    ev_last_name=(EditText)findViewById(R.id.edit_lname);
    ev_first_name=(EditText)findViewById(R.id.edit_fname);
    ev_email=(EditText)findViewById(R.id.edit_email);
    ev_password=(EditText)findViewById(R.id.edit_passwd);
    ev_confirm_password=(EditText)findViewById(R.id.edit_cpasswd);
    ev_phone=(EditText)findViewById(R.id.edit_phone);



    BtnSave.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
             last_name=ev_last_name.getText().toString();
             first_name=ev_first_name.getText().toString();
             email=ev_email.getText().toString();
             password=ev_password.getText().toString();
             confirm_password=ev_confirm_password.getText().toString();
             phone=ev_phone.getText().toString();

             if ((ev_last_name.getText().toString().length() <= 0))
             {
                 System.out.println(" The EditText is empty");
                 //I will use the toast later
             }


        }
    });


}
  • 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-08T20:38:14+00:00Added an answer on June 8, 2026 at 8:38 pm

    Use a “for” cycle.

    private boolean validate(EditText[] fields){
        for(int i = 0; i < fields.length; i++){
            EditText currentField = fields[i];
            if(currentField.getText().toString().length() <= 0){
                return false;
            }
        }
        return true;
    }
    

    and use the method like this:

    boolean fieldsOK = validate(new EditText[] { ev_last_name, ev_first_name, ev_email })
    

    will return true if all fields are non empty.

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

Sidebar

Related Questions

I have created two EditText fields and a single submit button in Android using
I have a few EditText fields in the same XML layout file, I'm using
I have a simple login layout that contains two EditText fields and a Button
I have EditText in my XML as <!-- Inside RelativeLayout --> <EditText android:id=@+id/edtEmail android:layout_width=match_parent
I have an Activity with some EditText fields and some buttons as a convenience
i have a small form with four EditText fields in which second EditText is
I have created a custom AlertDialog with multiple EditText fields using a custom layout.
I have two EditText and one Button in my Layout. If the two EditText
Hi I Have 3 tabs in one sceen.. first tab:some edittext fields with some
I have a a listview with each row having a text field and edittext

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.