diff --git a/Login App b/Login App new file mode 100644 index 0000000..86738de --- /dev/null +++ b/Login App @@ -0,0 +1,64 @@ +package com.example.devonte.logindemo; + +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; + +import org.w3c.dom.Text; + + +public class MainActivity extends AppCompatActivity { + + private EditText Name; + private EditText Password; + private TextView Info; + private Button Login; + private int counter = 5; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + + Name = (EditText)findViewById(R.id.etName); + Password = (EditText)findViewById(R.id.etPassword); + Info = (TextView)findViewById(R.id.tvinfo); + Login = (Button)findViewById(R.id.btnLogin); + + Info.setText("No of attempts remaining: 5"); + + + Login.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + validate(Name.getText().toString(), Password.getText().toString()); + + } + }); + + + } + + private void validate (String userName, String userPassword){ + if((userName.equals("Devonte")) && (userPassword.equals("1234"))) { + Intent intent = new Intent(MainActivity.this, SecondActivity.class); + startActivity(intent); + }else{ + counter--; + + Info.setText("No of attempts remaining:" + String.valueOf(counter)); + + + if(counter == 0){ + Login.setEnabled(false); + } + + } + + } +