Guest User

MainActivity

a guest
Mar 1st, 2016
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. import android.content.Intent;
  2. import android.support.v7.app.AppCompatActivity;
  3. import android.os.Bundle;
  4. import android.view.View;
  5. import android.widget.Button;
  6. import android.widget.EditText;
  7. import android.widget.Toast;
  8.  
  9. public class MainActivity extends AppCompatActivity {
  10.  
  11. Button logInButton;
  12. Button regButton;
  13. EditText username;
  14. EditText password;
  15.  
  16. @Override
  17. protected void onCreate(Bundle savedInstanceState) {
  18. super.onCreate(savedInstanceState);
  19. setContentView(R.layout.activity_main);
  20. username = (EditText) findViewById(R.id.username);
  21. password = (EditText) findViewById(R.id.password);
  22.  
  23.  
  24. logInButton = (Button) findViewById(R.id.login);
  25. logInButton.setOnClickListener(new View.OnClickListener() {
  26. @Override
  27. public void onClick(View v) {
  28. UserMenager um = UserMenager.getInstance();
  29. String user = username.getText().toString();
  30. String pass = password.getText().toString();
  31.  
  32. if (um.validateUser(user, pass)) {
  33. Toast.makeText(MainActivity.this, "hi" + user, Toast.LENGTH_SHORT).show();
  34. } else {
  35. password.setText("");
  36. password.setError("invalid pass");
  37. }
  38.  
  39.  
  40. }
  41. });
  42.  
  43. regButton = (Button) findViewById(R.id.register);
  44.  
  45. regButton.setOnClickListener(new View.OnClickListener() {
  46. @Override
  47. public void onClick(View v) {
  48. Intent intent = new Intent(MainActivity.this, RegActivity.class);
  49. startActivity(intent);
  50.  
  51. }
  52. });
  53.  
  54.  
  55.  
  56.  
  57.  
  58. }
  59.  
  60.  
  61. }
Add Comment
Please, Sign In to add comment