Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.sandra.calculatorconverter;
- import android.content.Intent;
- import android.graphics.PorterDuff;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.view.MotionEvent;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.ImageButton;
- public class LoginActivity extends AppCompatActivity {
- public static boolean logedin=false;
- Intent in;
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- if(logedin==true) {
- in = new Intent(LoginActivity.this, MainActivity.class);
- startActivity(in);
- finish();
- }
- setContentView(R.layout.login);
- Button enter=(Button)findViewById(R.id.button2);
- enter.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN: {
- v.getBackground().setColorFilter(0xe0f47521, PorterDuff.Mode.SRC_ATOP);
- v.invalidate();
- break;
- }
- case MotionEvent.ACTION_UP: {
- v.getBackground().clearColorFilter();
- v.invalidate();
- break;
- }
- }
- return false;
- }
- });
- enter.setOnClickListener(new OnClickListener()
- {
- @Override
- public void onClick(View v) {
- EditText username= (EditText) findViewById(R.id.editText7);
- EditText password=(EditText) findViewById(R.id.editText9);
- if(username.getText().toString().length()<=0 || password.getText().toString().length()<=0)
- {
- username.setHintTextColor(0xFFFF0000);
- password.setHintTextColor(0xFFFF0000);
- }
- else{
- MainActivity asd = new MainActivity();
- asd.ShowMessage = false;
- Intent intent = new Intent(LoginActivity.this, MainActivity.class);
- intent.putExtra("username", username.getText().toString());
- startActivity(intent);
- logedin=true;
- finish();
- }
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement