Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions Login App
Original file line number Diff line number Diff line change
@@ -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);
}

}

}