复习
解决AS,gradle问题
C:\Users\Lenovo.gradle\wrapper\dists在该路径,将下载好的gradle放在里面,再修改gradle-wrapper.properties中修改路径
#Sat Feb 17 18:06:10 CST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=file:///C:/Users/Lenovo/.gradle/wrapper/dists/gradle-8.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
再在设置里
将DIstribution和对应地址修改
再try again就可
页面
主题
Theme.MaterialComponents.DayNight.Bridge
编辑框样式
- 在"app/res/drawable"文件夹下新建xml文件“translucent_edit.xml”
 
<!--编辑框样式:在"app/res/drawable/translucent_edit.xml”下-->
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#DCDCDC" />
    <stroke android:width="1dip" android:color="#fefefe" />
    <corners android:radius="20dp"/>
    <padding android:bottom="10dp"
        android:left="10dp"
        android:right="10dp"
        android:top="10dp"/>
</shape>
按钮样式
- 在"app/res/drawable"文件夹下新建xml文件“translucent_button.xml”
 
<!--按钮样式:在"app/res/drawable/translucent_button.xml”下-->
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#4682B4" />
    <stroke android:width="1dip" android:color="#fefefe" />
    <corners android:radius="20dp"/>
    <padding android:bottom="10dp"
        android:left="10dp"
        android:right="10dp"
        android:top="10dp"/>
</shape>
登录界面
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
    <!--使用线性布局-->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:background="#F5F5F5">
        <!--Logo-->
        <ImageView
            android:id="@+id/LogoImage"
            android:layout_width="match_parent"
            android:layout_height="120dp"
            android:layout_marginTop="100dp"
            android:src="@drawable/gb2"/>
        <!--标题-->
        <TextView
            android:id="@+id/TitleText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="25dp"
            android:text="Timing•登录"
            android:gravity="center"
            android:textStyle="italic"
            android:textColor="#808080"
            android:textSize="30dp" />
        <!--嵌套线性布局-->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <!--嵌套线性布局-->
            <LinearLayout
                android:id="@+id/UserNameLayout"
                android:layout_width="match_parent"
                android:layout_height="match_parent">
                <!--用户名输入-->
                <EditText
                    android:id="@+id/UserNameEdit"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:padding="15dp"
                    android:layout_marginLeft="20dp"
                    android:layout_marginRight="20dp"
                    android:layout_marginTop="10dp"
                    android:layout_marginBottom="15dp"
                    android:background="@drawable/translucent_edit"
                    android:hint="输入用户名"
                    android:textSize="24dp"
                    android:singleLine="true" />
            </LinearLayout>
            <!--嵌套线性布局-->
            <LinearLayout
                android:id="@+id/PassWordLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <!--密码输入-->
                <EditText
                    android:id="@+id/PassWordEdit"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:padding="15dp"
                    android:layout_marginLeft="20dp"
                    android:layout_marginRight="20dp"
                    android:layout_marginTop="10dp"
                    android:layout_marginBottom="15dp"
                    android:background="@drawable/translucent_edit"
                    android:hint="输入用户密码"
                    android:textSize="24dp"
                    android:maxLength="16"
                    android:singleLine="true"
                    android:inputType="textPassword" />
            </LinearLayout>
            <!--嵌套线性布局-->
            <LinearLayout
                android:id="@+id/LayoutButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">
                <!--登录按钮-->
                <Button
                    android:id="@+id/LoginButton"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="15dp"
                    android:layout_margin="15dp"
                    android:layout_weight="1"
                    android:textColor="@color/cardview_light_background"
                    android:background="@drawable/translucent_button"
                    android:text="登   录"
                    android:textSize="24dp" />
                <!--注册按钮-->
                <Button
                    android:id="@+id/SignUpButton"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="15dp"
                    android:layout_margin="15dp"
                    android:layout_weight="1"
                    android:textColor="@color/cardview_light_background"
                    android:background="@drawable/translucent_button"
                    android:text="注   册"
                    android:textSize="24dp" />
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
注册界面
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".SignUpActivity">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:background="#F5F5F5">
        <!-- Logo -->
        <ImageView
            android:id="@+id/LogoImage"
            android:layout_width="match_parent"
            android:layout_height="120dp"
            android:layout_marginTop="50dp"
            android:src="@drawable/gb2"/>
        <!-- 标题 -->
        <TextView
            android:id="@+id/TitleText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="20dp"
            android:text="Timing•注册"
            android:gravity="center"
            android:textStyle="italic"
            android:textColor="#808080"
            android:textSize="30dp" />
        <!-- 学号输入 -->
        <EditText
            android:id="@+id/StudentIdEdit"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="10dp"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="10dp"
            android:background="@drawable/translucent_edit"
            android:hint="输入学号"
            android:textSize="24dp"
            android:singleLine="true" />
        <!-- 姓名输入 -->
        <EditText
            android:id="@+id/NameEdit"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="10dp"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="10dp"
            android:background="@drawable/translucent_edit"
            android:hint="输入姓名"
            android:textSize="24dp"
            android:singleLine="true" />
        <!-- 手机号输入 -->
        <EditText
            android:id="@+id/PhoneEdit"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="10dp"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="10dp"
            android:background="@drawable/translucent_edit"
            android:hint="输入手机号"
            android:textSize="24dp"
            android:singleLine="true" />
        <!-- 班级输入 -->
        <EditText
            android:id="@+id/ClassEdit"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="10dp"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="10dp"
            android:background="@drawable/translucent_edit"
            android:hint="输入班级"
            android:textSize="24dp"
            android:singleLine="true" />
        <!-- 密码输入 -->
        <EditText
            android:id="@+id/PasswordEdit"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="10dp"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="10dp"
            android:background="@drawable/translucent_edit"
            android:hint="输入密码"
            android:textSize="24dp"
            android:maxLength="16"
            android:singleLine="true"
            android:inputType="textPassword" />
        
        <!-- 按钮布局 -->
        <LinearLayout
            android:id="@+id/ButtonLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <!-- 立即注册按钮 -->
            <Button
                android:id="@+id/SignUpButton"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:padding="15dp"
                android:layout_margin="15dp"
                android:background="@drawable/translucent_button"
                android:text="立即注册"
                android:textColor="@color/dark"
                android:textSize="24dp" />
            <!-- 返回登录按钮 -->
            <Button
                android:id="@+id/BackLoginButton"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:padding="15dp"
                android:layout_margin="15dp"
                android:textColor="@color/dark"
                android:background="@drawable/translucent_button"
                android:text="返回登录"
                android:textSize="24dp" />
        </LinearLayout>
    </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
后端
数据库连接类
package com.example.demo2;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import androidx.annotation.Nullable;
public class DBOpenHelper extends SQLiteOpenHelper {
    public DBOpenHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }
    @Override
    public void onCreate(SQLiteDatabase db) {
    }
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    }
}
                    
                
                
            
        
浙公网安备 33010602011771号