Advertisement
Guest User

Untitled

a guest
Oct 7th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. package com.example.android.login;
  2.  
  3. import android.content.Intent;
  4. import android.os.Bundle;
  5. import android.support.v7.app.AppCompatActivity;
  6. import android.view.View;
  7. import android.widget.Button;
  8. import android.widget.EditText;
  9.  
  10. public class MainActivity extends AppCompatActivity {
  11.  
  12. private EditText username;
  13. private EditText Password;
  14.  
  15. private Button Login;
  16.  
  17.  
  18. @Override
  19. protected void onCreate(Bundle savedInstanceState) {
  20. super.onCreate(savedInstanceState);
  21. setContentView(R.layout.activity_main);
  22.  
  23.  
  24. username = (EditText) findViewById(R.id.etUsername);
  25.  
  26. Password = (EditText) findViewById(R.id.etPassword);
  27.  
  28. Login = (Button) findViewById(R.id.btnlogin);
  29.  
  30.  
  31. final String Username = username.getText().toString();
  32. final String password = Password.getText().toString();
  33. Login.setOnClickListener(new View.OnClickListener() {
  34. @Override
  35. public void onClick(View view) {
  36. Valid(Username, password);// This is the function that is not being called on clicking the button
  37. }
  38. }) ;
  39. }
  40.  
  41. public void Valid(String Username, String password) {
  42. if ((Username.equals("Admin")) && (password.equals("1234"))) {
  43. Intent intent = new Intent(MainActivity.this, com.example.android.login.userPage.class);
  44. startActivity(intent);
  45. }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement