Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.vollmon.schoolnavigator;
- import android.content.Intent;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.TextView;
- public class Login extends AppCompatActivity {
- private EditText etUsername;
- private EditText etPassword;
- private Button btnLogin;
- private TextView tvInfo;
- private int counter = 3;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_login);
- etUsername = (EditText) findViewById(R.id.etUsername);
- etPassword = (EditText) findViewById(R.id.etPassword);
- btnLogin = (Button) findViewById(R.id.btnLogin);
- tvInfo = (TextView) findViewById(R.id.tvInfo);
- tvInfo.setText("Anzahl verbleibender Versuche: 3");
- btnLogin.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- validate(etUsername.getText().toString(), etPassword.getText().toString());
- }
- });
- }
- private void validate (String userName, String userPassword) {
- if((userName.equals("Administrator")) && (userPassword.equals("1234"))) {
- Intent intent = new Intent(this, Overview_SecondPage.class);
- startActivity(intent);
- } else {
- counter--;
- tvInfo.setText("Anzahl verbleibender Versuche: " + String.valueOf(counter));
- if(counter == 0) {
- btnLogin.setEnabled(false);
- tvInfo.setText("Anmeldung fehlgeschlagen!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement