-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain1Activity.java
More file actions
41 lines (35 loc) · 1.26 KB
/
Main1Activity.java
File metadata and controls
41 lines (35 loc) · 1.26 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
package com.example.notepad;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class Main1Activity extends AppCompatActivity {
EditText pwd;
Button but;
int pass = 123;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main1);
pwd = findViewById(R.id.password);
but = findViewById(R.id.button);
but.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String psd = pwd.getText().toString();
if (psd.equals(pass)) {
Toast.makeText(Main1Activity.this, "Success", Toast.LENGTH_LONG).show();
Intent intent = new Intent(getApplicationContext(),MainActivity2.class );
startActivity(intent);
}
else{
Toast.makeText(Main1Activity.this,"Invalid credential",Toast.LENGTH_LONG).show();
}
}
});
}
}