-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainActivity.java
More file actions
65 lines (50 loc) · 1.75 KB
/
MainActivity.java
File metadata and controls
65 lines (50 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package www.logindemo;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import java.util.jar.Attributes;
public class MainActivity extends AppCompatActivity {
private EditText Email;
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);
Email = (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 reamining: 5");
Login.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
validate(Email.getText().toString(),Password.getText().toString());
}
});
}
private Object findViewByid(int etName) {
return null;
}
private void validate(String userEmail,String userPassword){
if((userEmail == "Admin@gmail.com") && (userPassword == "1234")){
Intent itent = new Intent(MainActivity.this,SecondActivity.class);
Intent intent = null;
startActivity(intent);
}
else{
counter--;
Info.setText("No of attempts remaining: "+String.valueOf(counter));
if(counter==0){
Login.setEnabled(false);
}
}
}
}