-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSignupActivity.java
More file actions
60 lines (50 loc) · 2.12 KB
/
SignupActivity.java
File metadata and controls
60 lines (50 loc) · 2.12 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
package com.example.pbl;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.widget.CheckBox;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.textfield.TextInputEditText;
public class SignupActivity extends AppCompatActivity {
private TextInputEditText nameInput, emailInput, passwordInput;
private CheckBox termsCheckbox;
private MaterialButton signupButton;
private TextView loginLink;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signup);
nameInput = findViewById(R.id.name_input);
emailInput = findViewById(R.id.email_input);
passwordInput = findViewById(R.id.password_input);
termsCheckbox = findViewById(R.id.terms_checkbox);
signupButton = findViewById(R.id.signup_button);
loginLink = findViewById(R.id.login_link);
signupButton.setOnClickListener(v -> {
if (!termsCheckbox.isChecked()) {
Toast.makeText(this, "Please accept the terms and conditions", Toast.LENGTH_SHORT).show();
return;
}
// Show loading
signupButton.setEnabled(false);
ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setMessage("Creating account...");
progressDialog.show();
// Simulate signup process
new Handler().postDelayed(() -> {
progressDialog.dismiss();
startActivity(new Intent(SignupActivity.this, LoginActivity.class));
finish();
}, 1500);
});
loginLink.setOnClickListener(v -> {
// Navigate back to login screen
startActivity(new Intent(SignupActivity.this, LoginActivity.class));
finish();
});
}
}