Guest User

new

a guest
Feb 5th, 2016
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. package com.example.yashu.helpinghands;
  2.  
  3. import android.content.Intent;
  4. import android.graphics.Paint;
  5. import android.support.v7.app.AppCompatActivity;
  6. import android.os.Bundle;
  7. import android.view.View;
  8. import android.widget.Button;
  9. import android.widget.EditText;
  10. import android.widget.TextView;
  11. import android.widget.Toast;
  12.  
  13. public class LoginActivity extends AppCompatActivity {
  14.  
  15. private static EditText username;
  16. private static EditText password;
  17. private static Button login_button;
  18. private static TextView link_signup;
  19.  
  20. @Override
  21. protected void onCreate(Bundle savedInstanceState) {
  22. super.onCreate(savedInstanceState);
  23. setContentView(R.layout.activity_login);
  24. LoginButton();
  25. }
  26.  
  27. public void LoginButton(){
  28. username = (EditText)findViewById(R.id.input_name);
  29. password = (EditText)findViewById(R.id.input_password);
  30. login_button = (Button)findViewById(R.id.btn_login);
  31. link_signup = (TextView)findViewById(R.id.link_signup);
  32.  
  33. //Underlined the text of "Dont have an account? Create one" from here
  34. link_signup.setPaintFlags(link_signup.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
  35.  
  36.  
  37. login_button.setOnClickListener(
  38. new View.OnClickListener()
  39. {
  40. @Override
  41. public void onClick(View v) {
  42. if (username.getText().toString().equals("user") || password.getText().toString().equals("pass"))
  43. {
  44. Toast.makeText(LoginActivity.this, "Username and password is correct",
  45. Toast.LENGTH_SHORT).show();
  46. Intent intent = new Intent(getBaseContext(), MapsActivity.class);
  47. startActivity(intent);
  48. }
  49. else
  50. {
  51. Toast.makeText(LoginActivity.this, "Username and password is NOT correct",
  52. Toast.LENGTH_SHORT).show();
  53. }
  54. }
  55. });
  56.  
  57. link_signup.setOnClickListener(new View.OnClickListener() {
  58. @Override
  59. public void onClick(View v) {
  60. // Start the Signup activity
  61. Intent intent = new Intent(getBaseContext(), RegisterActivity.class);
  62. startActivity(intent);
  63. }
  64. });
  65. }
  66.  
  67. }
Add Comment
Please, Sign In to add comment