Advertisement
Shishu

java log in

Oct 11th, 2019
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.53 KB | None | 0 0
  1. package com.example.user.shishu;
  2.  
  3. import android.os.Bundle;
  4. import android.support.v7.app.AppCompatActivity;
  5. import android.view.View;
  6. import android.view.View.OnClickListener;
  7. import android.widget.Button;
  8. import android.widget.EditText;
  9. import android.widget.TextView;
  10. import android.widget.Toast;
  11.  
  12. public class MainActivity extends AppCompatActivity {
  13.     EditText editText1, editText2;
  14.     TextView textView1, textView2, textView3;
  15.     Button button1, button2;
  16.  
  17.     String username1 = "shishu";
  18.     String password1 = "12345";
  19.  
  20.  
  21.     @Override
  22.     protected void onCreate(Bundle savedInstanceState) {
  23.         super.onCreate(savedInstanceState);
  24.         setContentView(R.layout.activity_main);
  25.  
  26.         editText1 = (EditText) findViewById(R.id.e1);
  27.         editText2 = (EditText) findViewById(R.id.e2);
  28.         button1 = (Button) findViewById(R.id.b1);
  29.         button2 = (Button) findViewById(R.id.b2);
  30.  
  31.  
  32.         button1.setOnClickListener(new OnClickListener() {
  33.             @Override
  34.             public void onClick(View v) {
  35.                 String username = editText1.getText().toString();
  36.                 String password = editText2.getText().toString();
  37.                 if (username.equals(username1) && password.equals(password1)) {
  38.                     Toast.makeText(getApplicationContext(), "Match", Toast.LENGTH_LONG).show();
  39.                 } else {
  40.                     Toast.makeText(getApplicationContext(), " Dont Match", Toast.LENGTH_LONG).show();
  41.                 }
  42.             }
  43.         });
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement