Guest User

Untitled

a guest
Oct 28th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. package org.trabalho;
  2.  
  3. import org.trabalho.R;
  4.  
  5. import android.app.Activity;
  6. import android.os.Bundle;
  7. import android.view.View;
  8. import android.view.View.OnClickListener;
  9. import android.widget.Button;
  10. import android.widget.EditText;
  11. import android.widget.TextView;
  12.  
  13. public class TelaDeLogin extends Activity {
  14.  
  15. private EditText nomeUsuario;
  16. private EditText senha;
  17. private Button botaoLogin;
  18. private Button botaoCancel;
  19. private TextView textoAviso;
  20.  
  21.  
  22.  
  23.  
  24. public void onCreate(Bundle savedInstanceState) {
  25. super.onCreate(savedInstanceState);
  26.  
  27. // Set Activity Layout
  28. setContentView(R.layout.main);
  29.  
  30. // Get the EditText and Button References
  31. nomeUsuario = (EditText)findViewById(R.id.username);
  32. senha = (EditText)findViewById(R.id.password);
  33. botaoLogin = (Button)findViewById(R.id.login_button);
  34. botaoCancel = (Button)findViewById(R.id.cancel_button);
  35. textoAviso = (TextView)findViewById(R.id.result);
  36.  
  37. // Set Click Listener
  38. botaoLogin.setOnClickListener(new OnClickListener() {
  39. public void onClick(View v) {
  40. String username = nomeUsuario.getText().toString();
  41. String password = senha.getText().toString();
  42.  
  43. if((username.equals("paulo") && password.equals("123"))||
  44. (username.equals("tici") && password.equals("123"))||
  45. (username.equals("leo") && password.equals("123"))){
  46. textoAviso.setText("Login efetuado com sucesso.");
  47.  
  48. Intent intent = new Intent();
  49. intent.putExtra("username", username);
  50. intent.setClass(TelaDeLogin.this, TelaDeNome.class);
  51. startActivity(intent);
  52. finish();
  53.  
  54. } else {
  55. textoAviso.setText("Falha de login. Nome de usuario e/ou senha incorreto.");
  56. }
  57. }
  58. });
  59. botaoCancel.setOnClickListener(new OnClickListener() {
  60. public void onClick(View v) {
  61. finish();
  62. }
  63. });
  64. }
  65.  
  66.  
  67.  
  68.  
  69. }
Add Comment
Please, Sign In to add comment