Advertisement
Guest User

main1

a guest
Nov 13th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. package com.example.bau.lab10ex2;
  2.  
  3. import android.content.Intent;
  4. import android.support.v7.app.AppCompatActivity;
  5. import android.os.Bundle;
  6. import android.view.View;
  7. import android.widget.Button;
  8. import android.widget.EditText;
  9. import android.widget.Toast;
  10.  
  11. public class MainActivity extends AppCompatActivity {
  12. EditText username, password;
  13. Button login;
  14.  
  15. @Override
  16. protected void onCreate(Bundle savedInstanceState) {
  17. super.onCreate(savedInstanceState);
  18. setContentView(R.layout.activity_main);
  19. login = (Button) findViewById(R.id.loginbtn);
  20. username = (EditText) findViewById(R.id.editText1);
  21. password = (EditText) findViewById(R.id.editText2);
  22.  
  23. login.setOnClickListener(new View.OnClickListener() {
  24. @Override
  25. public void onClick(View v) {
  26. if (username.getText().toString().equals("mohammadmerhi") && password.getText().toString().equals("123456")) {
  27. Intent intent = new Intent(MainActivity.this, Main2Activity.class);
  28. startActivity(intent);
  29. Toast.makeText(MainActivity.this, "Correct Username and Password", Toast.LENGTH_SHORT).show();
  30. } else {
  31. Toast.makeText(MainActivity.this, "Incorrect Username or Password", Toast.LENGTH_SHORT).show();
  32. }
  33. }
  34. });
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement