目录
学生签到系统通过账号密码登录,如果没有账号可以通过注册来创建一个新用户,如果是忘记了密码也可以通过忘记密码来找回密码(因为这个系统我没有连接数据库,创建新用户和找回密码是无法实现的),登录成功后就可以看到个人用户信息,然后对相应的课程进行签到。
一、登录界面
<TextView
android:id="@+id/tv_1_Login"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="2022年4月18日物联网201考勤情况:李x迟到,李x旷课,李x上课睡觉"
android:textSize="35dp"
android:background="#F40202"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="100dp"
android:text="物联网201考勤系统"
android:textSize="45dp"
android:gravity="center"
android:textColor="#F60909"
android:layout_marginTop="50dp"
/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:layout_marginTop="130dp"
>
<TextView
android:id="@+id/tv_2_Login"
android:layout_width="wrap_content"
android:layout_height="32dp"
android:text="账号:"
android:textSize="20dp"
android:gravity="center"
android:layout_marginTop="2dp"
/>
<EditText
android:id="@+id/et_1_Login"
android:layout_width="160dp"
android:layout_height="40dp"
android:layout_marginTop="2dp"
android:layout_toRightOf="@id/tv_2_Login"
android:gravity="center"
android:hint="手机号或邮箱"
android:textSize="15dp" />
<TextView
android:id="@+id/tv_3_Login"
android:layout_width="wrap_content"
android:layout_height="32dp"
android:layout_below="@id/tv_2_Login"
android:layout_marginTop="14dp"
android:gravity="center"
android:text="密码:"
android:textSize="20dp" />
<EditText
android:id="@+id/et_2_Login"
android:layout_width="160dp"
android:layout_height="40dp"
android:layout_below="@id/tv_2_Login"
android:layout_marginTop="14dp"
android:layout_toRightOf="@id/tv_3_Login"
android:gravity="center"
android:textSize="15dp" />
<Button
android:id="@+id/bt_1_Login"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_below="@id/tv_3_Login"
android:layout_marginLeft="90dp"
android:layout_marginTop="20dp"
android:background="@drawable/bt_1_solid_blue"
android:gravity="center"
android:text="登录"
android:textSize="27dp" />
<Button
android:id="@+id/bt_2_Login"
android:layout_width="65dp"
android:layout_height="32dp"
android:layout_toRightOf="@id/et_1_Login"
android:background="@drawable/bt_2_solid_yellow"
android:text="注册"
android:textSize="15dp"
/>
<Button
android:id="@+id/bt_3_Login"
android:layout_width="67dp"
android:layout_height="32dp"
android:layout_below="@id/bt_2_Login"
android:layout_marginTop="15dp"
android:layout_toRightOf="@id/et_2_Login"
android:background="@drawable/bt_3_stroke_yellow"
android:text="忘记密码"
android:textSize="15dp" />
<CheckBox
android:id="@+id/cb_1_Login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/bt_1_Login"
android:layout_marginLeft="65dp"
android:layout_marginTop="90dp"
android:background="@drawable/cb_1_stroke_blue"
android:checked="true"
android:text="我同意《xxx协议》"
android:textColor="#9F9D9D"
android:textSize="12dp" />
</RelativeLayout>
public class Login_Screen extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login_screen);
CheckBox cb_1_Login=findViewById(R.id.cb_1_Login);//复选框,在xml里面我设置为默认勾选
cb_1_Login.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);//设置下划线
TextView tv_1=findViewById(R.id.tv_1_Login);
tv_1.setSelected(true);//设置跑马灯效果
String user="admin";//设置用户名
String passorward="123456";//设置密码
EditText et_1_Login=findViewById(R.id.et_1_Login);//连接的是用户名编辑框
EditText et_2_Login=findViewById(R.id.et_2_Login);//连接的是密码编辑框
Button bt_1=findViewById(R.id.bt_1_Login);//连接的是登录按钮
bt_1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (cb_1_Login.isChecked()){
String user_code = et_1_Login.getText().toString();//获取输入的用户名
String passorward_code = et_2_Login.getText().toString();//获取输入的密码
if (user_code.isEmpty()){
Toast.makeText(Login_Screen.this,"请输入账号",Toast.LENGTH_SHORT).show();
}else {
if (passorward_code.isEmpty()){
Toast.makeText(Login_Screen.this,"请输入密码",Toast.LENGTH_SHORT).show();
}else {
if (user_code.equals(user)){
if (passorward_code.equals(passorward)){
Intent intent = new Intent(Login_Screen.this, User_Screen.class);
startActivity(intent);
}else {
Toast.makeText(Login_Screen.this,"密码错误,请重新输入",Toast.LENGTH_SHORT).show();
}
}else {
Toast.makeText(Login_Screen.this,"账号错误,请重新输入",Toast.LENGTH_SHORT).show();
}
}
}
}else {
Toast.makeText(Login_Screen.this,"请勾选协议",Toast.LENGTH_SHORT).show();
}
}
});
Button bt_2_Login=findViewById(R.id.bt_2_Login);//注册按钮的监听
bt_2_Login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(Login_Screen.this, Registered.class);
startActivity(intent);
}
});
Button bt_3_Login=findViewById(R.id.bt_3_Login);//忘记密码按钮的监听
bt_3_Login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(Login_Screen.this, Forgot_Password.class);
startActivity(intent);
}
});
}
}
我的登录系统是必须用户和密码以及勾选了用户协议才能登录成功
二、新用户注册界面
<TextView
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="新用户注册界面"
android:background="#A6F0FA"
and