注册页面及注册测试

自己慢慢敲得注册页面及注册测试

目前没有实现与数据库的联系

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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".RegisterActivity">
 
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_marginTop="40dp"
        android:gravity="center_vertical"
        >
 
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="账  号:"
            android:textSize="25sp"/>
 
        <EditText
            android:id="@+id/et_account"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:hint="请输入用户名或手机号"
            android:textSize="18sp"
            android:layout_marginLeft="10dp"
            android:background="@drawable/edit_text_bg"
            android:inputType="text"
            android:paddingLeft="5dp"
            />
    </LinearLayout>
 
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_marginTop="40dp"
        android:gravity="center_vertical"
        >
 
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="密  码:"
            android:textSize="25sp"/>
 
        <EditText
            android:id="@+id/et_password"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:hint="请输入密码"
            android:textSize="18sp"
            android:layout_marginLeft="10dp"
            android:background="@drawable/edit_text_bg"
            android:inputType="textPassword"
            android:paddingLeft="5dp"
            />
    </LinearLayout>
 
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_marginTop="40dp"
        android:gravity="center_vertical"
        >
 
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="确认密码:"
            android:textSize="25sp"/>
 
        <EditText
            android:id="@+id/et_password_confirm"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:hint="再次输入密码"
            android:textSize="18sp"
            android:layout_marginLeft="10dp"
            android:background="@drawable/edit_text_bg"
            android:inputType="textPassword"
            android:paddingLeft="5dp"
            />
    </LinearLayout>
 
 
    <Button
        android:id="@+id/btn_register"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="登录"
        android:textSize="25sp"
        android:layout_marginTop="20dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:textColor="@color/white"
        android:background="@drawable/btn_bg_selector"/>
 
    <CheckBox
        android:id="@+id/cb_agree"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@color/colorPrimary"
        android:text="还没有账号?"
        android:layout_gravity="left"
        android:layout_marginLeft="20dp"
        android:layout_marginTop="10dp"/>
 
</LinearLayout>

  

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
66
67
package com.example.logintest;
 
import androidx.appcompat.app.AppCompatActivity;
 
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Toast;
 
public class RegisterActivity extends AppCompatActivity implements View.OnClickListener {
 
    private Button btnRegister;
    private EditText etAccount, etPass,etPassConfirm;
    private CheckBox cbAgree;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);
        getSupportActionBar().setTitle("注册");
 
        btnRegister = findViewById(R.id.btn_register);
        etAccount = findViewById(R.id.et_account);
        etPass = findViewById(R.id.et_password);
        etPassConfirm = findViewById(R.id.et_password_confirm);
        cbAgree=findViewById(R.id.cb_agree);
 
        btnRegister.setOnClickListener(this);
 
 
    }
 
    @Override
    public void onClick(View view) {
        String name=etAccount.getText().toString();
        String pass=etPass.getText().toString();
        String passConfirm=etPassConfirm.getText().toString();
 
        if(TextUtils.isEmpty(name)){
            Toast.makeText(RegisterActivity.this,"用户名不能为空",Toast.LENGTH_LONG).show();
            return;
        }
 
        if(TextUtils.isEmpty(pass)){
            Toast.makeText(RegisterActivity.this,"密码不能为空",Toast.LENGTH_LONG).show();
            return;
        }
 
        if(!TextUtils.equals(pass,passConfirm)){
            Toast.makeText(RegisterActivity.this,"密码不一致",Toast.LENGTH_LONG).show();
            return;
        }
 
        if(!cbAgree.isChecked()){
            Toast.makeText(RegisterActivity.this,"请同意用户协议",Toast.LENGTH_LONG).show();
            return;
        }
 
        Toast.makeText(RegisterActivity.this,"注册成功",Toast.LENGTH_LONG).show();
 
 
    }
}

  

posted @   一统天下。  阅读(22)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· winform 绘制太阳,地球,月球 运作规律
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
点击右上角即可分享
微信分享提示