国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

安卓studio 個(gè)人課設(shè)項(xiàng)目:“這個(gè)app“——實(shí)現(xiàn)注冊(cè)登錄,顯示用戶信息功能,并跳轉(zhuǎn)對(duì)應(yīng)網(wǎng)頁(yè)

這篇具有很好參考價(jià)值的文章主要介紹了安卓studio 個(gè)人課設(shè)項(xiàng)目:“這個(gè)app“——實(shí)現(xiàn)注冊(cè)登錄,顯示用戶信息功能,并跳轉(zhuǎn)對(duì)應(yīng)網(wǎng)頁(yè)。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

目錄

目錄

功能說(shuō)明?

登錄頁(yè)面

注冊(cè)頁(yè)面

登錄后界面

點(diǎn)擊頭像出現(xiàn)側(cè)滑界面,并顯示用戶信息

點(diǎn)擊編輯按鈕進(jìn)入信息編輯頁(yè)面

?保存后返回

?用戶名已更改

跳轉(zhuǎn)網(wǎng)頁(yè)

相關(guān)代碼

布局

登錄界面

?注冊(cè)界面

?信息顯示界面

?主界面

實(shí)現(xiàn)側(cè)滑布局?

信息編輯界面

網(wǎng)頁(yè)顯示界面?

manifest?

邏輯代碼?

?LoginActivity

RegisterActivity

EditInformationActivity

RelaxActivity

StudyActivity

SlideActivity

實(shí)現(xiàn)側(cè)滑功能

網(wǎng)頁(yè)activity

網(wǎng)頁(yè)配置——SetWebView.class

?進(jìn)度條加載——SetProgressBar.class

?數(shù)據(jù)庫(kù)helper

user類

ToastUtil

結(jié)語(yǔ)

2022.11.12更新


功能說(shuō)明?

登錄頁(yè)面

安卓studio 個(gè)人課設(shè)項(xiàng)目:“這個(gè)app“——實(shí)現(xiàn)注冊(cè)登錄,顯示用戶信息功能,并跳轉(zhuǎn)對(duì)應(yīng)網(wǎng)頁(yè)

注冊(cè)頁(yè)面

能夠驗(yàn)證用戶名是否已存在,并判斷兩次密碼是否一致

?安卓studio 個(gè)人課設(shè)項(xiàng)目:“這個(gè)app“——實(shí)現(xiàn)注冊(cè)登錄,顯示用戶信息功能,并跳轉(zhuǎn)對(duì)應(yīng)網(wǎng)頁(yè)

登錄后界面

安卓studio 個(gè)人課設(shè)項(xiàng)目:“這個(gè)app“——實(shí)現(xiàn)注冊(cè)登錄,顯示用戶信息功能,并跳轉(zhuǎn)對(duì)應(yīng)網(wǎng)頁(yè)

點(diǎn)擊頭像出現(xiàn)側(cè)滑界面,并顯示用戶信息

當(dāng)前用戶無(wú)信息

?安卓studio 個(gè)人課設(shè)項(xiàng)目:“這個(gè)app“——實(shí)現(xiàn)注冊(cè)登錄,顯示用戶信息功能,并跳轉(zhuǎn)對(duì)應(yīng)網(wǎng)頁(yè)

點(diǎn)擊編輯按鈕進(jìn)入信息編輯頁(yè)面

編輯信息

?安卓studio 個(gè)人課設(shè)項(xiàng)目:“這個(gè)app“——實(shí)現(xiàn)注冊(cè)登錄,顯示用戶信息功能,并跳轉(zhuǎn)對(duì)應(yīng)網(wǎng)頁(yè)

?保存后返回

信息頁(yè)面顯示更改后的信息

安卓studio 個(gè)人課設(shè)項(xiàng)目:“這個(gè)app“——實(shí)現(xiàn)注冊(cè)登錄,顯示用戶信息功能,并跳轉(zhuǎn)對(duì)應(yīng)網(wǎng)頁(yè)

?用戶名已更改

修改用戶名后,下次登錄需要填寫更改后的用戶名

安卓studio 個(gè)人課設(shè)項(xiàng)目:“這個(gè)app“——實(shí)現(xiàn)注冊(cè)登錄,顯示用戶信息功能,并跳轉(zhuǎn)對(duì)應(yīng)網(wǎng)頁(yè)

跳轉(zhuǎn)網(wǎng)頁(yè)

點(diǎn)擊按鈕進(jìn)入相應(yīng)的網(wǎng)頁(yè) ,這里點(diǎn)擊? “長(zhǎng)知識(shí)”>>“菜鳥學(xué)編程”

?安卓studio 個(gè)人課設(shè)項(xiàng)目:“這個(gè)app“——實(shí)現(xiàn)注冊(cè)登錄,顯示用戶信息功能,并跳轉(zhuǎn)對(duì)應(yīng)網(wǎng)頁(yè)安卓studio 個(gè)人課設(shè)項(xiàng)目:“這個(gè)app“——實(shí)現(xiàn)注冊(cè)登錄,顯示用戶信息功能,并跳轉(zhuǎn)對(duì)應(yīng)網(wǎng)頁(yè)安卓studio 個(gè)人課設(shè)項(xiàng)目:“這個(gè)app“——實(shí)現(xiàn)注冊(cè)登錄,顯示用戶信息功能,并跳轉(zhuǎn)對(duì)應(yīng)網(wǎng)頁(yè)安卓studio 個(gè)人課設(shè)項(xiàng)目:“這個(gè)app“——實(shí)現(xiàn)注冊(cè)登錄,顯示用戶信息功能,并跳轉(zhuǎn)對(duì)應(yīng)網(wǎng)頁(yè)

相關(guān)代碼

布局

登錄界面

<?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:background="@drawable/bg_blue_orange"
    android:orientation="vertical"
    tools:context=".LoginActivity">

    <TextView
        android:id="@+id/textView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_marginTop="100dp"
        android:text="歡迎使用這個(gè)app!"
        android:textColor="@color/white"
        android:textSize="20sp" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginHorizontal="30dp"
        android:layout_marginTop="80dp"
        android:background="@drawable/bt_humditiy"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView10"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="3"
            android:text="用戶名:"
            android:textColor="@color/white"
            android:layout_marginLeft="5dp"
            android:textSize="18dp" />

        <EditText
            android:id="@+id/Ed_username"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:hint="@string/input_username"
            android:inputType="textPersonName"
            android:textColor="@color/white" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginHorizontal="30dp"
        android:layout_marginTop="30dp"
        android:background="@drawable/bt_humditiy"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView11"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="3"
            android:text="密碼:"
            android:textColor="@color/white"
            android:layout_marginLeft="5dp"
            android:textSize="18dp" />

        <EditText
            android:id="@+id/Ed_password"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:ems="10"
            android:hint="@string/input_password"
            android:inputType="textPassword"
            android:textColor="@color/white"
            android:textColorHighlight="@color/white" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="80dp"
        android:orientation="horizontal">

        <Button
            android:id="@+id/bt_login"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:background="@drawable/bt_humditiy"
            android:text="@string/login"
            android:textColor="@color/white"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:textSize="20sp" />

        <Button
            android:id="@+id/bt_register"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@drawable/bt_humditiy"
            android:text="@string/registered"
            android:textColor="@color/white"
            android:layout_marginRight="20dp"
            android:layout_marginLeft="20dp"
            android:textSize="24sp" />
    </LinearLayout>

</LinearLayout>

?注冊(cè)界面

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:background="@drawable/bg_blue_orange"
    tools:context=".RegisterActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <TextView
            android:id="@+id/register_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="注冊(cè)"
            android:textSize="40dp"
            android:textColor="@color/white"
            android:layout_marginTop="20dp"
            android:layout_marginStart="160dp"/>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="120dp"
            android:background="@drawable/bt_humditiy"
            android:layout_marginHorizontal="20dp"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/textView7"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="3"
                android:textColor="@color/white"
                android:textSize="18dp"
                android:layout_marginLeft="5dp"
                android:text="用戶名:" />

            <EditText
                android:id="@+id/set_username"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:ems="10"
                android:hint="請(qǐng)輸入用戶名:"
                android:inputType="textPersonName" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:background="@drawable/bt_humditiy"
            android:layout_marginHorizontal="20dp"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/textView8"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="3"
                android:textColor="@color/white"
                android:textSize="18dp"
                android:layout_marginLeft="5dp"
                android:text="密碼:" />

            <EditText
                android:id="@+id/set_userPassword1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:ems="10"
                android:hint="請(qǐng)輸入密碼:"
                android:inputType="textPassword" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:background="@drawable/bt_humditiy"
            android:layout_marginHorizontal="20dp"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/textView9"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="3"
                android:textColor="@color/white"
                android:textSize="18dp"
                android:layout_marginLeft="5dp"
                android:text="確認(rèn)密碼:" />

            <EditText
                android:id="@+id/set_userPassword2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:ems="10"
                android:hint="再次輸入密碼:"
                android:inputType="textPassword" />
        </LinearLayout>

        <Button
            android:id="@+id/bt_startRegister"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="80dp"
            android:layout_marginHorizontal="100dp"
            android:background="@drawable/bt_humditiy"
            android:textColor="@color/white"
            android:textSize="20dp"
            android:text="點(diǎn)擊注冊(cè)" />
    </LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

?信息顯示界面

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="270dp"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/bg_purple_miror">

    <TextView
        android:id="@+id/tv_userInformation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="個(gè)人信息"
        android:textColor="@color/white"
        android:textSize="25dp" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/tv_age"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:layout_weight="3"
            android:text="年齡:"
            android:textColor="@color/white"
            android:textSize="22dp" />

        <TextView
            android:id="@+id/tv_userAge"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/white"
            android:layout_weight="1"
            android:textSize="22dp"
            android:layout_marginTop="20dp"
            android:text="TextView" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/tv_sex"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="3"
            android:text="性別:"
            android:textColor="@color/white"
            android:textSize="22dp" />

        <TextView
            android:id="@+id/tv_userSex"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textColor="@color/white"
            android:textSize="22dp"
            android:text="TextView" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/tv_favorite"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="3"
            android:text="愛好:"
            android:textColor="@color/white"
            android:textSize="22dp" />

        <TextView
            android:id="@+id/tv_userFavorite"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textColor="@color/white"
            android:textSize="22dp"
            android:text="TextView" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_marginTop="20dp"
        android:orientation="vertical">

        <TextView
            android:id="@+id/tv_signature"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="個(gè)性簽名:"
            android:textColor="@color/white"
            android:textSize="20dp" />

        <TextView
            android:id="@+id/tv_userSignature"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="9"
            android:textColor="@color/white"
            android:textSize="22dp"
            android:text="TextView" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <Button
            android:id="@+id/bt_toEdit"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="200dp"
            android:background="@color/bitGrey"
            android:paddingLeft="180dp"
            android:text="編輯>"
            android:textColor="@color/white"
            android:textSize="30dp" />
    </LinearLayout>

</LinearLayout>

?主界面

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/bg_purple">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_marginTop="10dp">

        <ImageView
            android:id="@+id/iv_head"
            android:layout_width="60dp"
            android:layout_height="wrap_content"
            android:src="@mipmap/head1"
            android:layout_marginTop="5dp"
            android:layout_marginLeft="10dp"
            android:scaleType="centerCrop"/>

        <TextView
            android:id="@+id/tv_username"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:text="user_冰川"
            android:textSize="30dp"
            android:layout_margin="10dp"
            android:textColor="@color/white"/>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="15dp"
        android:layout_marginTop="200dp"
        android:orientation="vertical">

        <Button
            android:id="@+id/btn_study"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="40dp"
            android:text="長(zhǎng)知識(shí)"
            android:background="@drawable/bt_humditiy"
            android:textColor="@color/white"/>

        <Button
            android:id="@+id/btn_relax"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="40dp"
            android:text="找點(diǎn)樂子"
            android:background="@drawable/bt_humditiy"
            android:textColor="@color/white"/>

    </LinearLayout>

</LinearLayout>

實(shí)現(xiàn)側(cè)滑布局?

<?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=".SlideActivity">

    <com.example.myfirst.util.SlideMenu
        android:id="@+id/slideMenu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <!--        信息界面布局-->
        <include layout="@layout/layout_menu" />

        <!--        主界面布局-->
        <include
            layout="@layout/layout_main"
            android:layout_width="wrap_content"
            android:layout_height="743dp" />
    </com.example.myfirst.util.SlideMenu>

</LinearLayout>

信息編輯界面

<?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"
    android:background="@drawable/bg_green_blue"
    tools:context=".EditInformationActivity">

    <TextView
        android:id="@+id/Tv_EditInformation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="信息編輯"
        android:textColor="@color/white"
        android:textSize="30sp" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/bitGrey"
        android:layout_marginTop="120dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:textColor="@color/white"
            android:textSize="25dp"
            android:layout_marginLeft="10dp"
            android:text="用戶名:" />

        <EditText
            android:id="@+id/Et_EditUsername"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:ems="10"
            android:inputType="textPersonName"
            android:textColor="@color/white"
            android:textSize="20dp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/bitGrey"
        android:layout_marginTop="20dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:textColor="@color/white"
            android:textSize="25dp"
            android:layout_marginLeft="10dp"
            android:text="年齡:" />

        <EditText
            android:id="@+id/Et_editAge"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:ems="10"
            android:inputType="textPersonName"
            android:textColor="@color/white"
            android:textSize="20dp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/bitGrey"
        android:layout_marginTop="20dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:textColor="@color/white"
            android:textSize="25dp"
            android:layout_marginLeft="10dp"
            android:text="性別:" />

        <RadioGroup
            android:id="@+id/rg_sex"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            android:layout_weight="1">

            <RadioButton
                android:id="@+id/rdB_male"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="男" />

            <RadioButton
                android:id="@+id/rdB_female"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="女" />

        </RadioGroup>

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/bitGrey"
        android:layout_marginTop="20dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView5"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:textColor="@color/white"
            android:textSize="25dp"
            android:layout_marginLeft="10dp"
            android:text="愛好:" />

        <EditText
            android:id="@+id/Et_editFavorite"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:ems="10"
            android:inputType="textPersonName"
            android:textColor="@color/white"
            android:textSize="20dp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/bitGrey"
        android:layout_marginTop="20dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView6"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:textColor="@color/white"
            android:textSize="25dp"
            android:layout_marginLeft="10dp"
            android:text="個(gè)性簽名:" />

        <EditText
            android:id="@+id/Et_editSignature"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:ems="10"
            android:inputType="textPersonName"
            android:textColor="@color/white"
            android:textSize="20dp" />
    </LinearLayout>
    <Button
        android:id="@+id/bt_saveInformation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="100dp"
        android:layout_marginHorizontal="100dp"
        android:background="@drawable/bt_humditiy"
        android:textColor="@color/white"
        android:textSize="30dp"
        android:text="保存" />


</LinearLayout>

網(wǎng)頁(yè)顯示界面?

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
    tools:context=".RunoobActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <ProgressBar
            android:id="@+id/pb_run_oob"
            style="?android:attr/progressBarStyleHorizontal"
            android:max="100"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <WebView
            android:id="@+id/wv_runOob"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

manifest?

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myfirst">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/this_app"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/this_app"
        android:supportsRtl="true"
        android:theme="@style/Theme.Myfirst"
        android:usesCleartextTraffic="true">
        <activity
            android:name=".FlowerActivity"
            android:exported="false" />
        <activity
            android:name=".EndlessLakeActivity"
            android:exported="false" />
        <activity
            android:name=".SpaceActivity"
            android:exported="false" />
        <activity
            android:name=".DeepSeaActivity"
            android:exported="false" />
        <activity
            android:name=".AnswerActivity"
            android:exported="false" />
        <activity
            android:name=".MedicineActivity"
            android:exported="false" />
        <activity
            android:name=".TechnologyMuseumActivity"
            android:exported="false" />
        <activity
            android:name=".RunoobActivity"
            android:exported="false" />
        <activity
            android:name=".EditInformationActivity"
            android:exported="false" />
        <activity
            android:name=".RegisterActivity"
            android:exported="false" /> <!-- 防止net::ERR_CLEARTEXT_NOT_PERMITTED -->
        <activity
            android:name=".WhichoneActivity"
            android:exported="false" />
        <activity
            android:name=".LoopTapActivity"
            android:exported="false" />
        <activity
            android:name=".HenxiangsiActivity"
            android:exported="false" />
        <activity
            android:name=".MikutapActivity"
            android:exported="false" />
        <activity
            android:name=".SummondragonActivity"
            android:exported="false" />
        <activity
            android:name=".EatwhatActivity"
            android:exported="false" />
        <activity
            android:name=".WebZTypeActivity"
            android:exported="false" />
        <activity
            android:name=".RelaxActivity"
            android:exported="false" />
        <activity
            android:name=".StudyActivity"
            android:exported="false" />
        <activity
            android:name=".SlideActivity"
            android:exported="true" />
        <activity
            android:name=".LoginActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

邏輯代碼?

?LoginActivity

package com.example.myfirst;

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 com.example.myfirst.util.DBHelper;
import com.example.myfirst.util.ToastUtil;
import com.example.myfirst.util.User;

import java.util.ArrayList;

public class LoginActivity extends AppCompatActivity implements View.OnClickListener {
                                 //當(dāng)需要用到新的onClick()時(shí),要 implements View.OnClickListener
    private Button mBtLogin;            //聲明變量
    private EditText mEtUser;
    private EditText mEtPassword;
    private Button mBtRegister;
    private DBHelper dbHelper;
    public static int userId;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);

        mBtLogin = findViewById(R.id.bt_login);
        mEtPassword = findViewById(R.id.Ed_password);
        mEtUser = findViewById(R.id.Ed_username);
        mBtRegister = findViewById(R.id.bt_register);

        dbHelper = new DBHelper(this);
        mBtLogin.setOnClickListener(this);       //當(dāng)需要用到新的onClick()時(shí),就用this
        mBtRegister.setOnClickListener(this);
    }

    public void onClick(View view){
        switch (view.getId()){
            case R.id.bt_login:
                String username = mEtUser.getText().toString().trim();
                String password = mEtPassword.getText().toString().trim();

                if(!TextUtils.isEmpty(username) && !TextUtils.isEmpty(password)){
                    ArrayList<User> userData = dbHelper.getData();  //在User list創(chuàng)建一個(gè)實(shí)例userData
                    boolean judge = false;                          //并讓userData獲取數(shù)據(jù)庫(kù)里的數(shù)據(jù)
                    for (int i = 0; i < userData.size(); i++){
                        User user = userData.get(i);
                        if (username.equals(user.getName()) && password.equals(user.getPassword())){
                            judge = true;
                            userId = i;
                            break;
                        }              //遍歷user id,當(dāng)輸入的用戶名和密碼與數(shù)據(jù)庫(kù)里的數(shù)據(jù)匹配則judge=true
                        else {
                            judge = false;
                        }
                    }
                    if (judge){
                        ToastUtil.showMsg(LoginActivity.this,"登陸成功!");
                        Intent intent2 = new Intent(this,SlideActivity.class);
                        startActivity(intent2);
                        finish();
                    }
                    else {
                        ToastUtil.showMsg(LoginActivity.this,"用戶名錯(cuò)誤或密碼錯(cuò)誤!");
                    }
                }
                else {
                    ToastUtil.showMsg(LoginActivity.this,"用戶名或密碼不能為空");
                }
                break;
            case R.id.bt_register:
                Intent intent1 = new Intent(LoginActivity.this,RegisterActivity.class);
                startActivity(intent1);
                break;
        }
    }
    public  static int getUserId(){
        return userId;
    }
}

RegisterActivity

package com.example.myfirst;

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 com.example.myfirst.util.DBHelper;
import com.example.myfirst.util.ToastUtil;

public class RegisterActivity extends AppCompatActivity implements View.OnClickListener{

    private Button mBtToRegister;
    private DBHelper dbHelper;
    private EditText mEtSetUsername;
    private EditText mEtSetUserPassword1;
    private EditText mEtSetUserPassword2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);

        mEtSetUsername = findViewById(R.id.set_username);
        mEtSetUserPassword1 = findViewById(R.id.set_userPassword1);
        mEtSetUserPassword2 = findViewById(R.id.set_userPassword2);
        mBtToRegister = findViewById(R.id.bt_startRegister);

        dbHelper = new DBHelper(this);
        mBtToRegister.setOnClickListener(this);
    }

    public void onClick(View view){
        String username = mEtSetUsername.getText().toString().trim();
        String password1 = mEtSetUserPassword1.getText().toString().trim();
        String password2 = mEtSetUserPassword2.getText().toString().trim();

        if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(password1)&& !TextUtils.isEmpty(password2)  ) {
                if ((password1.equals(password2))) {
                    if (dbHelper.add(username, password2)){
                        //將用戶名和密碼加入到數(shù)據(jù)庫(kù)中
                        Intent intent2 = new Intent(this, LoginActivity.class);
                        startActivity(intent2);
                        finish();
                        ToastUtil.showMsg(RegisterActivity.this,"注冊(cè)成功!");
                    }
                    else {
                        ToastUtil.showMsg(RegisterActivity.this,"該用戶名已存在!");
                    }
                }
                else {
                    ToastUtil.showMsg(RegisterActivity.this,"密碼輸入不一致");
                }
        }
        else {
            ToastUtil.showMsg(RegisterActivity.this,"用戶名和密碼不能為空!");
        }
    }
}

EditInformationActivity

信息編輯activity

package com.example.myfirst;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.example.myfirst.util.DBHelper;
import com.example.myfirst.util.ToastUtil;
import com.example.myfirst.util.User;

import java.util.ArrayList;

public class EditInformationActivity extends AppCompatActivity implements View.OnClickListener{

    private EditText mEtUsername,mEtAge,mEtFavorite,mEtSignature;
    private Button mBtSaveInformation;
    private DBHelper dbHelper;
    private RadioButton mRbMale,mRbFemale;
    private String sexString;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edit_infor);

        mEtUsername = findViewById(R.id.Et_EditUsername);
        mEtAge = findViewById(R.id.Et_editAge);
        mRbMale = findViewById(R.id.rdB_male);
        mRbFemale = findViewById(R.id.rdB_female);
        mEtFavorite = findViewById(R.id.Et_editFavorite);
        mEtSignature = findViewById(R.id.Et_editSignature);
        mBtSaveInformation = findViewById(R.id.bt_saveInformation);

        dbHelper = new DBHelper(this);

        showRadioButtonIsCheck();

        mBtSaveInformation.setOnClickListener(this);
    }

    private void showRadioButtonIsCheck(){            //定義一個(gè)根據(jù)用戶性別顯示 哪個(gè)radiobutton被選中的方法
        ArrayList<User> userData = dbHelper.getData();
        User user = userData.get(LoginActivity.getUserId());

        if (!(user.getSex() == null)){
            if (user.getSex().equals("男")){
                mRbMale.setChecked(true);
            }else if (user.getSex().equals("女")){
                mRbFemale.setChecked(true);
            }
        }
    }

    @Override
    public void onClick(View view) {
        String username = mEtUsername.getText().toString().trim();
        String age = mEtAge.getText().toString();
        String favorite = mEtFavorite.getText().toString();
        String signature = mEtSignature.getText().toString();         //分別獲取輸入的用戶信息

        if (!username.isEmpty()){
            dbHelper.updateUsername(username);
        }
        if (!age.isEmpty()){
            dbHelper.updateAge(age);
        }

        if (mRbMale.isChecked()){
            sexString = "男";
        }else if (mRbFemale.isChecked()){
            sexString = "女";
        }
        dbHelper.updateSex(sexString);

        if (!favorite.isEmpty()){
            dbHelper.updateFavorite(favorite);
        }
        if (!signature.isEmpty()){
            dbHelper.updateSignature(signature);        //分別保存到數(shù)據(jù)庫(kù)中的User表,必須做一個(gè)是否為空的檢查
        }                                               //否則表中數(shù)據(jù)可能會(huì)被覆蓋

        SlideActivity.slideActivity.finish();              //更改后銷毀原來(lái)的信息顯示頁(yè)面
        ToastUtil.showMsg(this,"更改成功");
        Intent intent = new Intent(EditInformationActivity.this,SlideActivity.class);
        startActivity(intent);
        finish();

    }
}

RelaxActivity

娛樂

package com.example.myfirst;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class RelaxActivity extends AppCompatActivity {

    private Button btnGame1,btnGame2,btnGame3,btnGame4,btnGame5,btnGame6,btnGame7,btnGame8,btnGame9;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_relax);

        btnGame1 = findViewById(R.id.bt_game1);
        btnGame2 = findViewById(R.id.bt_game2);
        btnGame3 = findViewById(R.id.bt_game3);
        btnGame4 = findViewById(R.id.bt_game4);
        btnGame5 = findViewById(R.id.bt_game5);
        btnGame6 = findViewById(R.id.bt_game6);
        btnGame7 = findViewById(R.id.bt_game7);
        btnGame8 = findViewById(R.id.bt_game8);
        btnGame9 = findViewById(R.id.bt_game9);

        setClickListener();
    }
    private class OnClick implements View.OnClickListener{      //新建私有類OnClick,實(shí)現(xiàn)View.OnClickListener
        @Override                                               //重寫onClick方法
        public void onClick(View view) {
            Intent intent = null;
            switch (view.getId()){
                case R.id.bt_game1:
                    intent = new Intent(RelaxActivity.this,WebZTypeActivity.class);
                    break;
                case R.id.bt_game2:
                    intent = new Intent(RelaxActivity.this,EatwhatActivity.class);
                    break;
                case R.id.bt_game3:
                    intent = new Intent(RelaxActivity.this, SummondragonActivity.class);
                    break;
                case R.id.bt_game4:
                    intent = new Intent(RelaxActivity.this,WhichoneActivity.class);
                    break;
                case R.id.bt_game5:
                    intent = new Intent(RelaxActivity.this,MikutapActivity.class);
                    break;
                case R.id.bt_game6:
                    intent = new Intent(RelaxActivity.this,HenxiangsiActivity.class);
                    break;
                case R.id.bt_game7:
                    intent = new Intent(RelaxActivity.this, LoopTapActivity.class);
                    break;
                case R.id.bt_game8:
                    intent = new Intent(RelaxActivity.this, FlowerActivity.class);
                    break;
                case R.id.bt_game9:
                    intent = new Intent(RelaxActivity.this, EndlessLakeActivity.class);
                    break;
            }
            startActivity(intent);
        }
    }
    //設(shè)計(jì)方法
    private void setClickListener(){
        OnClick onClick = new OnClick();       //在OnClick新建onClick實(shí)體,否則36行OnClick是灰色的,也就是沒被調(diào)用
        btnGame1.setOnClickListener(onClick); //每個(gè)button都調(diào)用監(jiān)聽,并用上面的方法
        btnGame2.setOnClickListener(onClick);
        btnGame3.setOnClickListener(onClick);
        btnGame4.setOnClickListener(onClick);
        btnGame5.setOnClickListener(onClick);
        btnGame6.setOnClickListener(onClick);
        btnGame7.setOnClickListener(onClick);
        btnGame8.setOnClickListener(onClick);
        btnGame9.setOnClickListener(onClick);
    }
}

StudyActivity

學(xué)習(xí)

package com.example.myfirst;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.SearchEvent;
import android.view.View;
import android.widget.Button;

public class StudyActivity extends AppCompatActivity {

    private Button btnStudy1,btnStudy2,btnStudy3,btnStudy4,btnStudy5,btnStudy6;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_study);

        btnStudy1 = findViewById(R.id.btn_study1);
        btnStudy2 = findViewById(R.id.btn_study2);
        btnStudy3 = findViewById(R.id.btn_study3);
        btnStudy4 = findViewById(R.id.btn_study4);
        btnStudy5 = findViewById(R.id.btn_study5);
        btnStudy6 = findViewById(R.id.btn_study6);

        setClickListener();
    }

    private class OnClick implements View.OnClickListener{     //新建私有類OnClick,與 View.OnClickListener接口對(duì)接
        @Override
        public void onClick(View view) {
            Intent intent = null;
            switch (view.getId()){
                case R.id.btn_study1:
                    intent = new Intent(StudyActivity.this,RunoobActivity.class);
                    break;
                case R.id.btn_study2:
                    intent = new Intent(StudyActivity.this,TechnologyMuseumActivity.class);
                    break;
                case R.id.btn_study3:
                    intent = new Intent(StudyActivity.this,MedicineActivity.class);
                    break;
                case R.id.btn_study4:
                    intent = new Intent(StudyActivity.this,AnswerActivity.class);
                    break;
                case R.id.btn_study5:
                    intent = new Intent(StudyActivity.this,SpaceActivity.class);
                    break;
                case R.id.btn_study6:
                    intent = new Intent(StudyActivity.this, DeepSeaActivity.class);
                    break;
            }
            startActivity(intent);
        }
    }
    private void setClickListener(){
        OnClick onClick = new OnClick();
        btnStudy1.setOnClickListener(onClick);
        btnStudy2.setOnClickListener(onClick);
        btnStudy3.setOnClickListener(onClick);
        btnStudy4.setOnClickListener(onClick);
        btnStudy5.setOnClickListener(onClick);
        btnStudy6.setOnClickListener(onClick);          //每個(gè)button都調(diào)用監(jiān)聽,并用上面的方法
    }
}

SlideActivity

側(cè)滑

package com.example.myfirst;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.myfirst.util.DBHelper;
import com.example.myfirst.util.SlideMenu;
import com.example.myfirst.util.User;

import java.util.ArrayList;

public class SlideActivity extends AppCompatActivity {

    private ImageView mIvHead;
    private SlideMenu slideMenu;
    private Button buttonStudy;
    private Button buttonRelax;
    private Button buttonToEdit;
    private TextView mTvUsername,mTvSex,mTvAge,mTvFavorite,mTvSignature;
    private DBHelper dbHelper;

    public static SlideActivity slideActivity;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_slide);
        slideActivity = this;

        mIvHead = findViewById(R.id.iv_head);
        slideMenu = findViewById(R.id.slideMenu);
        buttonStudy = findViewById(R.id.btn_study);
        buttonRelax = findViewById(R.id.btn_relax);
        buttonToEdit = findViewById(R.id.bt_toEdit);

        mTvUsername = findViewById(R.id.tv_username);               //用戶信息顯示控件
        mTvSex = findViewById(R.id.tv_userSex);
        mTvAge = findViewById(R.id.tv_userAge);
        mTvFavorite = findViewById(R.id.tv_userFavorite);
        mTvSignature = findViewById(R.id.tv_userSignature);

        mIvHead.setOnClickListener(v -> slideMenu.switchMenu());

        setClickListener();

        dbHelper = new DBHelper(this);
        showUserInformation();
    }
//由于button太多,設(shè)計(jì)一個(gè)方法,設(shè)計(jì)方法之前寫好要調(diào)用的類
    private class OnClick implements View.OnClickListener{      //新建私有類OnClick,實(shí)現(xiàn)View.OnClickListener
        @Override                                               //重寫onClick方法
        public void onClick(View view) {
            Intent intent = null;
            switch (view.getId()){
                case R.id.btn_study:
                    intent = new Intent(SlideActivity.this,StudyActivity.class);
                    break;
                case R.id.btn_relax:
                    intent = new Intent(SlideActivity.this,RelaxActivity.class);
                    break;
                case R.id.bt_toEdit:
                    intent = new Intent(SlideActivity.this,EditInformationActivity.class);
            }
            startActivity(intent);
        }
    }
//設(shè)計(jì)方法
    private void setClickListener(){
        OnClick onClick = new OnClick();         //在OnClick新建onClick實(shí)體,否則36行OnClick是灰色的,也就是沒被調(diào)用
        buttonStudy.setOnClickListener(onClick); //每個(gè)button都調(diào)用監(jiān)聽,并用上面的方法
        buttonRelax.setOnClickListener(onClick);
        buttonToEdit.setOnClickListener(onClick);
    }

    private void showUserInformation() {                          //建立獲取用戶信息的方法
        ArrayList<User> userData2 = dbHelper.getData();           //創(chuàng)建User隊(duì)列 userData2
        User user = userData2.get(LoginActivity.getUserId());      //創(chuàng)建一個(gè)實(shí)體user,并獲取當(dāng)前用戶id的數(shù)據(jù)
        mTvUsername.setText(user.getName());
        mTvAge.setText(user.getAge());
        mTvSex.setText(user.getSex());
        mTvFavorite.setText(user.getFavorite());                  //分別獲取用戶信息到TV控件
        mTvSignature.setText(user.getSignature());
    }
}

實(shí)現(xiàn)側(cè)滑功能

這里是使用了別人封裝好的類,??(順帶一提,小姐姐在b站的教學(xué)視頻很好)?b站材料1-代碼之側(cè)滑界面的java文件_小小小白冷的博客-CSDN博客

package com.example.myfirst.util;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.Scroller;

public class SlideMenu extends FrameLayout {
    private View menuView,mainView;
    private int menuWidth;
    private Scroller scroller;
    public SlideMenu(Context context) {
        super(context);
        init();
    }
    public SlideMenu(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }
    private void init(){
        scroller = new Scroller(getContext());
    }
    /**
     * 當(dāng)1級(jí)子view全部加載完調(diào)用,可以用初始化子view引用
     * 注意這里無(wú)法獲取子view的寬高
     */
    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        menuView = getChildAt(0);
        mainView = getChildAt(1);
        menuWidth = menuView.getLayoutParams().width;
    }
    //使Menu也具有滑動(dòng)功能
    public boolean onInterceptTouchEvent(MotionEvent ev){
        switch (ev.getAction()) {
            case MotionEvent.ACTION_DOWN:
                downX = (int) ev.getX();
                break;
            case MotionEvent.ACTION_MOVE:
                int deltaX = (int) (ev.getX() - downX);
                if (Math.abs(deltaX) > 8){
                    return true;
                }
                break;
        }
        return super.onInterceptTouchEvent(ev);
    }

    /**
     * s設(shè)置兩個(gè)子view在頁(yè)面上的布局
     * @param l:當(dāng)前子view的左邊在父view的坐標(biāo)系的x坐標(biāo)
     * @param t:當(dāng)前子view的頂邊在父view的坐標(biāo)系的y坐標(biāo)
     * @param r:當(dāng)前子view的寬
     * @param b:當(dāng)前子view的高
     */
    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        menuView.layout(-menuWidth, 0, 0, b);
        mainView.layout(0, 0, r, b);
    }

    /**
     * 處理屏幕滑動(dòng)事件
     */
    private int downX;
    public boolean onTouchEvent(MotionEvent event) {
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                downX = (int) event.getX();
                break;
            case MotionEvent.ACTION_MOVE:
                int moveX = (int) event.getX();
                int deltaX = moveX - downX;
                int newScrollX = getScrollX() - deltaX;
                if (newScrollX < -menuWidth) newScrollX = -menuWidth;
                if (newScrollX > 0) newScrollX = 0;
                scrollTo(newScrollX, 0);
                downX = moveX;
                break;
            case MotionEvent.ACTION_UP:
                //當(dāng)滑動(dòng)距離小于Menu寬度的一半時(shí),平滑滑動(dòng)到主頁(yè)面
                if(getScrollX()>-menuWidth/2){
                    closeMenu();
                }else {
                    //當(dāng)滑動(dòng)距離大于Menu寬度的一半時(shí),平滑滑動(dòng)到Menu頁(yè)面
                    openMenu();
                }
                break;
        }
        return true;
    }
    //關(guān)閉menu
    private void closeMenu(){
        scroller.startScroll(getScrollX(),0,0-getScrollX(),0,400);
        invalidate();
    }
    //打開menu
    private void openMenu(){
        scroller.startScroll(getScrollX(),0,-menuWidth-getScrollX(),0,400);
        invalidate();
    }
    /**
     * Scroller不主動(dòng)去調(diào)用這個(gè)方法
     * 而invalidate()可以調(diào)用這個(gè)方法
     * invalidate->draw->computeScroll
     */
    public void computeScroll(){
        super.computeScroll();
        if(scroller.computeScrollOffset()){
            //返回true,表示動(dòng)畫沒結(jié)束
            scrollTo(scroller.getCurrX(),0);
            invalidate();
        }
    }
    /**
     * 切換菜單的開和關(guān)
     */
    public void switchMenu(){
        if(getScrollX()==0){
            openMenu();
        }else {
            closeMenu();
        }
    }

}


網(wǎng)頁(yè)activity

每個(gè)網(wǎng)頁(yè)activity的內(nèi)容步驟都一樣,這里以菜鳥編程為例

package com.example.myfirst;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;

import com.example.myfirst.util.SetProgressBar;
import com.example.myfirst.util.SetWebView;

public class RunoobActivity extends AppCompatActivity {

    private WebView webView;
    private String url = "https://www.runoob.com/";
    private ProgressBar progressBar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_runoob);

        webView = findViewById(R.id.wv_runOob);
        progressBar = findViewById(R.id.pb_run_oob);

        SetProgressBar.setProgressBar(webView,progressBar);
        SetWebView.setWebView(webView,url);
    }
}

網(wǎng)頁(yè)配置——SetWebView.class

package com.example.myfirst.util;

import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class SetWebView {
    public static void setWebView(WebView webView,String url){

        webView.getSettings().setSupportZoom(true);                        //設(shè)置可以支持縮放

        webView.getSettings().setBuiltInZoomControls(true);                //設(shè)置出現(xiàn)縮放工具

        webView.getSettings().setUseWideViewPort(true);                    //擴(kuò)大比例的縮放

        webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
                                                                            //自適應(yīng)屏幕,也就是不能左右滑動(dòng)

        webView.getSettings().setLoadWithOverviewMode(true);                //加載完全縮小的WebView

        webView.getSettings().setJavaScriptEnabled(true);                  //支持JavaScript

        webView.getSettings().setAppCacheEnabled(true);                    //開啟應(yīng)用緩存

        webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);      //設(shè)置緩存模式

        webView.getSettings().setDomStorageEnabled(true);                  //開啟 DOM storage API 功能

        webView.setWebViewClient(new WebViewClient(){       //防止訪問網(wǎng)頁(yè)時(shí)跳轉(zhuǎn)到外部頁(yè)面
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {   //防止跳轉(zhuǎn)到外部瀏覽器
                return false;
            }
        });
        webView.loadUrl(url);
    }
}

?進(jìn)度條加載——SetProgressBar.class

package com.example.myfirst.util;

import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.widget.ProgressBar;

public class SetProgressBar {                    //單獨(dú)建立一個(gè)加載進(jìn)度條的類和方法

    public static void setProgressBar(WebView webView,ProgressBar progressBar){

        webView.setWebChromeClient(new WebChromeClient(){
            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                super.onProgressChanged(view, newProgress);

                if (newProgress == 100){
                    progressBar.setVisibility(View.GONE);           //加載完成后消失
                }else {
                    progressBar.setVisibility(View.VISIBLE);        //未加載完成則可見
                    progressBar.setProgress(newProgress);           //讓控件獲取當(dāng)前加載進(jìn)度
                }
            }
        });
    }
}

?數(shù)據(jù)庫(kù)helper

package com.example.myfirst.util;

import android.annotation.SuppressLint;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import java.util.ArrayList;

public class DBHelper extends SQLiteOpenHelper {
    private SQLiteDatabase db;

    public DBHelper(Context context){                  //構(gòu)造函數(shù)
        super(context,"db_thisApp",null,1);
        db = getReadableDatabase();
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("create table if not exists user(" +
                "_id integer primary key autoincrement,"+
                "name text,"+
                "password text," +
                "sex text," +
                "age text," +
                "favorite text," +
                "signature text" +
                ")");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("drop table if exists user");
        onCreate(db);
    }

    public boolean add(String name, String password){           //驗(yàn)證用戶名是否已存在并注冊(cè)
        boolean judge2 = true;
        ArrayList<User> userData = this.getData(); //在User list創(chuàng)建一個(gè)實(shí)例userData,并讓userData獲取數(shù)據(jù)庫(kù)里的數(shù)據(jù)
        for (int i = 0; i < userData.size(); i++){
            User user = userData.get(i);
            if (name.equals(user.getName())){
                judge2 = false;
                break;
            }              //遍歷user id,當(dāng)輸入的用戶名已存在則false
        }
        if (judge2){
            db.execSQL("insert into user(name,password) values(?,?)", new Object[]{name,password});
        }
        return judge2;
    }                                                     // 需要用Object[]把值傳進(jìn) ?中

    public void delete(String name,String password){
        db.execSQL("delete from user where name = and password =" + name + password);
    }

    public void update(String name,String password){
        db.execSQL("update user set password = ?",new Object[]{password});
    }

    public void updateUsername(String name){
        db.execSQL("update user set name = ?", new Object[]{name});       //創(chuàng)建一個(gè)更新用戶信息的DB方法
    }

    public void updateSex(String sex){
        db.execSQL("update user set sex = ?", new Object[]{sex});
    }

    public void updateAge(String age){
        db.execSQL("update user set age = ?", new Object[]{age});
    }

    public void updateFavorite(String favorite){
        db.execSQL("update user set favorite = ?", new Object[]{favorite});
    }

    public void updateSignature(String signature){
        db.execSQL("update user set signature = ?", new Object[]{signature});
    }

    public ArrayList<User> getData(){
        //從數(shù)據(jù)庫(kù)獲取數(shù)據(jù)到list中
        ArrayList<User> userList = new ArrayList<User>();             //隊(duì)列,以User結(jié)構(gòu)建立隊(duì)列,也就是建立User隊(duì)列
        Cursor cursor = db.query("user",null,null,
                                null,
                                null,
                                null,
                                "name desc");
        while (cursor.moveToNext()){                     //因?yàn)関alue must be>0,所以不能使用moveToFirst,否則程序會(huì)崩潰:
            @SuppressLint("Range") String name = cursor.getString(cursor.getColumnIndex("name"));
            @SuppressLint("Range") String password = cursor.getString(cursor.getColumnIndex("password"));
            @SuppressLint("Range") String sex = cursor.getString(cursor.getColumnIndex("sex"));
            @SuppressLint("Range") String age = cursor.getString(cursor.getColumnIndex("age"));
            @SuppressLint("Range") String favorite = cursor.getString(cursor.getColumnIndex("favorite"));
            @SuppressLint("Range") String signature = cursor.getString(cursor.getColumnIndex("signature"));
            userList.add(new User(name,password,sex,age,favorite,signature));
        }
        cursor.close();                      //游標(biāo)一定要關(guān)掉?。?!不然遍歷過后會(huì)停留在最后一個(gè)位置,語(yǔ)句的位置也很講究
        return userList;                        //從表中遍歷的值依次存入list中
    }
}

?這里考慮到真實(shí)情況下,用戶進(jìn)去可能只更新一種屬性,所以把用戶的每種屬性實(shí)現(xiàn)了單獨(dú)更新

user類

package com.example.myfirst.util;

public class User {                          //構(gòu)造User結(jié)構(gòu)
    private String name;
    private String password;
    private String sex,age,favorite,signature;
    public User(String name,String password,String sex,String age,String favorite,String signature){
        this.name = name;
        this.password = password;
        this.sex = sex;
        this.age = age;
        this.favorite = favorite;
        this.signature = signature;
    }

    public String getName() {
        return name;
    }

    public String getPassword() {
        return password;
    }

    public String getSex(){
        return sex;
    }

    public String getAge(){
        return age;
    }

    public String getFavorite(){
        return favorite;
    }

    public String getSignature(){
        return signature;
    }

}

ToastUtil

這個(gè)是用來(lái)學(xué)習(xí)而創(chuàng)建的,上面的一些activity都用到了這里面的方法,無(wú)關(guān)緊要,可以直接Toast.makeText()

package com.example.myfirst.util;

import android.content.Context;
import android.widget.Toast;

public class ToastUtil {
    public static Toast mToast;
    public static void showMsg(Context context,String msg){
      if(mToast == null){
          mToast = Toast.makeText(context,msg,Toast.LENGTH_SHORT);
       }
       else{
          mToast.setText(msg);
       }
       mToast.show();

    }             
}

結(jié)語(yǔ)

這個(gè)項(xiàng)目是邊學(xué)邊做的,所以有些注釋看起來(lái)是多余的,而且有些地方肯定不夠好,有時(shí)間再學(xué)習(xí)并實(shí)現(xiàn)? 用戶上傳頭像功能,搜索并添加好友功能

2022.11.12更新

下面是整個(gè)項(xiàng)目的壓縮包,需要的可以自取

鏈接:https://pan.baidu.com/s/1vvN-xUjXGXVjJri4RWofQQ?pwd=vjif?
提取碼:vjif

項(xiàng)目里還加了更換頭像的功能,不過只適應(yīng)較低的安卓版本,大概不超過安卓9吧,個(gè)別手機(jī)系統(tǒng)也不行,比如小米和vivo

這是7月弄的,很就沒碰了,最近在弄微信小程序,所以要是有什么問題問我可能答不上來(lái),請(qǐng)見諒文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-426310.html

到了這里,關(guān)于安卓studio 個(gè)人課設(shè)項(xiàng)目:“這個(gè)app“——實(shí)現(xiàn)注冊(cè)登錄,顯示用戶信息功能,并跳轉(zhuǎn)對(duì)應(yīng)網(wǎng)頁(yè)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 基于安卓的五子棋游戲畢業(yè)設(shè)計(jì)(?。。〔恢惯@個(gè)項(xiàng)目,很多基于安卓基于小程序的項(xiàng)目都可以)

    基于 Android 的五子棋系統(tǒng)開發(fā) 摘 要 移動(dòng)互聯(lián)網(wǎng)時(shí)代的到來(lái)極大的改變了我們的生活,而Android是一種以Linux為基礎(chǔ)的開放源碼操作系統(tǒng)迅速占領(lǐng)了智能機(jī)操作系統(tǒng),所以在Android 環(huán)境下開發(fā)顯得尤為必要,本文詳細(xì)介紹了在Android平臺(tái)上以Java為語(yǔ)言編寫游戲的過程。五子棋游戲

    2024年02月10日
    瀏覽(16)
  • Android Studio App開發(fā)實(shí)戰(zhàn)項(xiàng)目之實(shí)現(xiàn)淘寶電商App首頁(yè)界面(附源碼,可用于大作業(yè)參考)

    Android Studio App開發(fā)實(shí)戰(zhàn)項(xiàng)目之實(shí)現(xiàn)淘寶電商App首頁(yè)界面(附源碼,可用于大作業(yè)參考)

    需要源碼和圖片集請(qǐng)點(diǎn)贊關(guān)注收藏后評(píng)論區(qū)留言或者私信~~~ 各家電商的App首頁(yè)都是動(dòng)感十足,頁(yè)面元素豐富令人眼花繚亂,其中運(yùn)用了Android的多種組合控件,可以說(shuō)是App界面開發(fā)的集大成之作,下面我們也動(dòng)手實(shí)現(xiàn)一個(gè)。 本次項(xiàng)目主要模仿淘寶App采用的技術(shù),所以有底部標(biāo)

    2024年02月03日
    瀏覽(24)
  • [Kotlin]手把手教你寫一個(gè)安卓APP(第一章注冊(cè)登錄)

    [Kotlin]手把手教你寫一個(gè)安卓APP(第一章注冊(cè)登錄)

    開發(fā)軟件:Android Studio 1.創(chuàng)建項(xiàng)目默認(rèn)選擇Empty Activity ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?點(diǎn)擊Next ?2.生成項(xiàng)目設(shè)置包名選擇開發(fā)語(yǔ)言(這里我用的是kotlin) ?在生成項(xiàng)目后我們要做的就是添加需要的配置打開我們的app目錄下的 buil

    2023年04月23日
    瀏覽(32)
  • Android Studio —— Activity組件(課后作業(yè):登錄和注冊(cè)App)

    Android Studio —— Activity組件(課后作業(yè):登錄和注冊(cè)App)

    運(yùn)行效果圖 ? 主界面(初始),注冊(cè)界面,登錄界面,主界面(注冊(cè)和登錄之后) 實(shí)現(xiàn)步驟 1.設(shè)計(jì)主界面,編寫activity_main.xml 注:(1) 按鈕的格式是自己設(shè)計(jì)的,如下 注:(2)需編寫strings.xml 2.創(chuàng)建兩個(gè)activity(會(huì)自動(dòng)創(chuàng)建對(duì)應(yīng)的layout布局文件) ? 3.設(shè)計(jì)登錄和注冊(cè)界面,編寫

    2024年02月05日
    瀏覽(29)
  • Android安卓實(shí)戰(zhàn)項(xiàng)目---登陸注冊(cè)頁(yè)面(源碼在文末)

    Android安卓實(shí)戰(zhàn)項(xiàng)目---登陸注冊(cè)頁(yè)面(源碼在文末)

    效果圖: 這段代碼是一個(gè)簡(jiǎn)單的Android應(yīng)用中的登錄功能代碼,下面逐行解釋其功能和作用: 導(dǎo)入相關(guān)的類和包: 這些導(dǎo)入語(yǔ)句引入了用于構(gòu)建Android應(yīng)用界面、處理用戶交互和數(shù)據(jù)存儲(chǔ)的必要類和包。 定義一個(gè)名為 LoginActivity 的類,它繼承自 AppCompatActivity ,表示這是一個(gè)用

    2024年02月13日
    瀏覽(23)
  • 安卓大作業(yè):使用Android Studio開發(fā)天氣預(yù)報(bào)APP(使用sqlite數(shù)據(jù)庫(kù))

    安卓大作業(yè):使用Android Studio開發(fā)天氣預(yù)報(bào)APP(使用sqlite數(shù)據(jù)庫(kù))

    今天我來(lái)分享一下如何使用Android Studio開發(fā)一個(gè)天氣預(yù)報(bào)APP。在文中,我們將使用第三方接口獲取實(shí)時(shí)天氣數(shù)據(jù),并顯示在APP界面上。 首先,打開Android Studio并創(chuàng)建一個(gè)新的項(xiàng)目。在創(chuàng)建新項(xiàng)目時(shí),我們需要設(shè)置項(xiàng)目名稱、包名和支持的最低API級(jí)別。 為了獲取實(shí)時(shí)天氣數(shù)據(jù),

    2024年02月08日
    瀏覽(30)
  • Android Studio心得-創(chuàng)建登錄注冊(cè)項(xiàng)目

    ? ? ? ? 首先先了解AndroidStudio是什么:Android Studio是一個(gè)由谷歌開發(fā)的Android應(yīng)用程序開發(fā)環(huán)境,用于開發(fā)Android應(yīng)用程序。它基于JetBrains IntelliJIDEA軟件,并包含了許多定制化功能,包括易于使用的分析工具、內(nèi)存分析工具和代碼編輯器等,支持Java、Kotlin等多種編程語(yǔ)言。An

    2024年02月05日
    瀏覽(18)
  • 安卓期末項(xiàng)目:星座App

    安卓期末項(xiàng)目:星座App

    目錄 一,項(xiàng)目介紹: 二,項(xiàng)目功能介紹 ?????????1 查看星座 ?????????2 星座匹配 ?????????3 查看運(yùn)勢(shì) ????????4 本軟件介紹? 三,核心代碼 (1)首頁(yè)Mactivity核心代碼 (2)首頁(yè)查看星座 (3)星座的匹配 ??(4)查看運(yùn)勢(shì) ?????????(5)本軟件介紹 四,項(xiàng)

    2024年02月08日
    瀏覽(30)
  • [Android Studio] 導(dǎo)入安卓Android項(xiàng)目教程

    [Android Studio] 導(dǎo)入安卓Android項(xiàng)目教程

    A項(xiàng)目指:要導(dǎo)入的項(xiàng)目;B項(xiàng)目指自己電腦上可以運(yùn)行的項(xiàng)目 根據(jù)步驟一步一步來(lái),別急。 將要導(dǎo)入的項(xiàng)目(簡(jiǎn)稱為A)根目錄下的這些文件刪掉:.gradle、.idea 、.iml后綴的文件、 local.properties 進(jìn)入app文件夾,將這些文件刪掉:build、.iml后綴的文件 打開一個(gè)你在自己電腦上可

    2024年02月04日
    瀏覽(18)
  • 用 Android Studio 打包 uni-app 的安卓apk;手把手教程、巨詳細(xì)避坑

    用 Android Studio 打包 uni-app 的安卓apk;手把手教程、巨詳細(xì)避坑

    Uni-app 離線打包 apk 1. Android Studio 下載 Android Studio官網(wǎng) 2. HBuilderX下載 HBuilderX下載 3. App離線SDK下載 Android 離線SDK - 正式版 下載后解壓文件,將 HBuilder-Integrate-AS 重命名 build-template 并拷貝到一個(gè)專門打包用的文件夾下作為打包模板 該文件夾中有一個(gè) simpleDemo 文件夾 即 build-temp

    2024年02月04日
    瀏覽(85)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包