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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:28:11+00:00 2026-06-03T09:28:11+00:00

EditText txtUserName; EditText txtPassword; Button btnLogin; Button btnCancel; /** Called when the activity is

  • 0
EditText txtUserName;
 EditText txtPassword;
 Button btnLogin;
 Button btnCancel;

    /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.main);


     txtUserName=(EditText)this.findViewById(R.id.txtUname);
     txtPassword=(EditText)this.findViewById(R.id.txtPwd);
     btnLogin=(Button)this.findViewById(R.id.btnLogin);
         btnLogin.setOnClickListener(new OnClickListener() {

             @Override
             public void onClick(View v) {            
                     Intent myIntent = new Intent(v.getContext(), AddName.class);
                     startActivityForResult(myIntent, 0);
                 if((txtUserName.getText().toString()).equals(txtPassword.getText().toString())){
                     Toast.makeText(LoginappActivity.this, "Login Successful",Toast.LENGTH_LONG).show();
                    } else{
                     Toast.makeText(LoginappActivity.this, "Invalid Login",Toast.LENGTH_LONG).show(); 
                     }
                       }
                          });

 }           
       }

i have created a login page for my app. while i am running in my emulator if the password and username matches it should go to next screen but while running this if the username and password is wrong the app is going to second page can anyone suggest

  • 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-03T09:28:13+00:00Added an answer on June 3, 2026 at 9:28 am
    package com.app.NewProjectHttpDemo;
    
    import java.io.InputStream;
    import java.net.URL;
    import java.util.ArrayList;
    
    import android.content.Context;
    import android.graphics.drawable.Drawable;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.ArrayAdapter;
    import android.widget.ImageView;
    import android.widget.TextView;
    
    EditText txtUserName;
     EditText txtPassword;
     Button btnLogin;
     Button btnCancel;
    
        /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);
    
    
         txtUserName=(EditText)this.findViewById(R.id.txtUname);
         txtPassword=(EditText)this.findViewById(R.id.txtPwd);
         btnLogin=(Button)this.findViewById(R.id.btnLogin);
             btnLogin.setOnClickListener(new OnClickListener() {
    
                 @Override
                 public void onClick(View v) {            
    
                     if((txtUserName.getText().toString()).equals(txtPassword.getText().toString())){
     Intent myIntent = new Intent(v.getContext(), AddName.class);
                         startActivityForResult(myIntent, 1);
                         Toast.makeText(LoginappActivity.this, "Login Successful",Toast.LENGTH_LONG).show();
                        } else{
                         Toast.makeText(LoginappActivity.this, "Invalid Login",Toast.LENGTH_LONG).show(); 
                         }
                           }
                              });
    
     }           
           }
    

    Replace this code with your code,this will work perfectly

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

Sidebar

Related Questions

EditText txtUserName; EditText txtPassword; Button btnLogin; Button btnCancel; /** Called when the activity is
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); txtUserName=(EditText)this.findViewById(R.id.txtUname); txtPassword=(EditText)this.findViewById(R.id.txtPwd); btnLogin=(Button)this.findViewById(R.id.btnLogin); Button btnLogin=(Button)this.findViewById(R.id.Button01); btnLogin.setOnClickListener(new
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); txtUserName=(EditText)this.findViewById(R.id.txtUname); txtPassword=(EditText)this.findViewById(R.id.txtPwd); btnLogin=(Button)this.findViewById(R.id.btnLogin); btnLogin=(Button)this.findViewById(R.id.btnLogin); btnLogin.setOnClickListener(new OnClickListener()
I have a EditText object created in the main activity in onCreate. I need
public class BabyName extends Activity implements View.OnClickListener, Runnable{ /** Called when the activity is
I have a EditText , a textView and a button, I need to set
I have 2 EditText's in my layout. In the first I shuld put the
I have a Button/Edittext to reset my App-Settings.... If a press the button(no long
How to get EditText's value from sub-Activity? With a condition that if I click
I have this EditText field inside of one activity, and I want it so

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.