Advertisement
Guest User

Untitled

a guest
Nov 11th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.59 KB | None | 0 0
  1. package com.example.sandra.calculatorconverter;
  2.  
  3. import android.content.Intent;
  4. import android.graphics.PorterDuff;
  5. import android.support.v7.app.AppCompatActivity;
  6. import android.os.Bundle;
  7. import android.view.MotionEvent;
  8. import android.view.View;
  9. import android.view.View.OnClickListener;
  10. import android.widget.Button;
  11. import android.widget.EditText;
  12. import android.widget.ImageButton;
  13.  
  14. public class LoginActivity extends AppCompatActivity {
  15.  
  16.     public static boolean logedin=false;
  17.     Intent in;
  18.     protected void onCreate(Bundle savedInstanceState) {
  19.         super.onCreate(savedInstanceState);
  20.         if(logedin==true) {
  21.             in = new Intent(LoginActivity.this, MainActivity.class);
  22.             startActivity(in);
  23.             finish();
  24.         }
  25.         setContentView(R.layout.login);
  26.         Button enter=(Button)findViewById(R.id.button2);
  27.         enter.setOnTouchListener(new View.OnTouchListener() {
  28.             @Override
  29.             public boolean onTouch(View v, MotionEvent event) {
  30.                 switch (event.getAction()) {
  31.                     case MotionEvent.ACTION_DOWN: {
  32.                         v.getBackground().setColorFilter(0xe0f47521, PorterDuff.Mode.SRC_ATOP);
  33.                         v.invalidate();
  34.                         break;
  35.                     }
  36.                     case MotionEvent.ACTION_UP: {
  37.                         v.getBackground().clearColorFilter();
  38.                         v.invalidate();
  39.                         break;
  40.                     }
  41.                 }
  42.                 return false;
  43.             }
  44.         });
  45.         enter.setOnClickListener(new OnClickListener()
  46.         {
  47.             @Override
  48.             public void onClick(View v) {
  49.                 EditText username= (EditText) findViewById(R.id.editText7);
  50.                 EditText password=(EditText) findViewById(R.id.editText9);
  51.  
  52.  
  53.                 if(username.getText().toString().length()<=0 || password.getText().toString().length()<=0)
  54.                 {
  55.                     username.setHintTextColor(0xFFFF0000);
  56.                     password.setHintTextColor(0xFFFF0000);
  57.                 }
  58.  
  59.                 else{
  60.                     MainActivity asd = new MainActivity();
  61.                     asd.ShowMessage = false;
  62.                     Intent intent = new Intent(LoginActivity.this, MainActivity.class);
  63.                     intent.putExtra("username", username.getText().toString());
  64.                     startActivity(intent);
  65.                     logedin=true;
  66.                     finish();
  67.                 }
  68.  
  69.             }
  70.         });
  71.  
  72.  
  73.     }
  74.  
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement