Advertisement
huertz

p movil UI main

Apr 18th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package pe.edu.ulima.login;
  2.  
  3. import android.support.v7.app.AppCompatActivity;
  4. import android.os.Bundle;
  5. import android.util.Log;
  6. import android.view.View;
  7. import android.widget.Button;
  8. import android.widget.EditText;
  9. import android.widget.TextView;
  10. import android.widget.Toast;
  11.  
  12. public class MainActivity extends AppCompatActivity
  13.         implements View.OnClickListener, View.OnLongClickListener{
  14.     //TextView tviMensaje;
  15.     EditText eteUsername, etePassword;
  16.  
  17.     @Override
  18.     protected void onCreate(Bundle savedInstanceState) {
  19.         super.onCreate(savedInstanceState);
  20.         setContentView(R.layout.activity_main);
  21.         //tviMensaje = (TextView) findViewById(R.id.tviMensaje);
  22.         eteUsername = (EditText) findViewById(R.id.eteUsername);
  23.         etePassword = (EditText) findViewById(R.id.etePassword);
  24.         Button butClick = (Button) findViewById(R.id.butClick);
  25.         Button butSalir = (Button) findViewById(R.id.butSalir);
  26.         //LoginClickListener loginClickListener = new LoginClickListener();
  27.         //butClick.setOnClickListener(loginClickListener);
  28.         butClick.setOnClickListener(this);
  29.         //butSalir.setOnClickListener(this);
  30.         butSalir.setOnLongClickListener(this);
  31.     }
  32.  
  33.     @Override
  34.     public void onClick(View view) {
  35.         //Log.i("TAG","Se hizo click.");
  36.         //tviMensaje.setText("Se hizo click.");
  37.         if (view.getId() == R.id.butClick) {
  38.             if (eteUsername.getText().toString().equals("android")
  39.                     && etePassword.getText().toString().equals("1234")) {
  40.                 //Login correcto
  41.                 Toast.makeText(this, "Login correcto", Toast.LENGTH_LONG).show();
  42.             } else {
  43.                 //Login incorrecto
  44.                 eteUsername.setText("");
  45.                 etePassword.setText("");
  46.                 Toast.makeText(this, "Error en login", Toast.LENGTH_LONG).show();
  47.             }
  48.         }else if (view.getId() == R.id.butSalir){
  49.             // Deberia salir de la app
  50.             finish();
  51.         }
  52.     }
  53.  
  54.     @Override
  55.     public boolean onLongClick(View view) {
  56.         finish();
  57.         return false;
  58.     }
  59. }
  60.  
  61.  
  62. public class LoginClickListener implements View.OnClickListener {
  63.  
  64.     @Override
  65.     public void onClick(View view) {
  66.         Log.i("TAG","Se hizo click.");
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement