Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.trabalho;
- import org.trabalho.R;
- import android.app.Activity;
- import android.os.Bundle;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.TextView;
- public class TelaDeLogin extends Activity {
- private EditText nomeUsuario;
- private EditText senha;
- private Button botaoLogin;
- private Button botaoCancel;
- private TextView textoAviso;
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- // Set Activity Layout
- setContentView(R.layout.main);
- // Get the EditText and Button References
- nomeUsuario = (EditText)findViewById(R.id.username);
- senha = (EditText)findViewById(R.id.password);
- botaoLogin = (Button)findViewById(R.id.login_button);
- botaoCancel = (Button)findViewById(R.id.cancel_button);
- textoAviso = (TextView)findViewById(R.id.result);
- // Set Click Listener
- botaoLogin.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- String username = nomeUsuario.getText().toString();
- String password = senha.getText().toString();
- if((username.equals("paulo") && password.equals("123"))||
- (username.equals("tici") && password.equals("123"))||
- (username.equals("leo") && password.equals("123"))){
- textoAviso.setText("Login efetuado com sucesso.");
- Intent intent = new Intent();
- intent.putExtra("username", username);
- intent.setClass(TelaDeLogin.this, TelaDeNome.class);
- startActivity(intent);
- finish();
- } else {
- textoAviso.setText("Falha de login. Nome de usuario e/ou senha incorreto.");
- }
- }
- });
- botaoCancel.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- finish();
- }
- });
- }
- }
Add Comment
Please, Sign In to add comment