第三周星期三每日总结

      今日简单对第一次个人作业的注册登录页面进行了学习和编写,通过学习我了解了如何在不使用数据库情况下和使用数据库情况下的登录注册系统的编写,不使用数据库为简易程序,账户密码被固定在程序中,使用数据库则同javaweb存储在Android Studio自带数据库中。同时我学习了如何创建新Activity,以及如何实现在各个页面间的跳转。

xml代码文件:

、activity_main.xml

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
 3     xmlns:app="http://schemas.android.com/apk/res-auto"
 4     xmlns:tools="http://schemas.android.com/tools"
 5     android:layout_width="match_parent"
 6     android:layout_height="match_parent"
 7     tools:context=".MainActivity">
 8 
 9     <LinearLayout
10         android:layout_width="match_parent"
11         android:layout_height="match_parent"
12         android:orientation="vertical">
13         <LinearLayout
14             android:layout_width="match_parent"
15             android:layout_height="wrap_content"
16             android:layout_marginTop="10dp"
17             android:orientation="horizontal">
18             <TextView
19                 android:layout_width="0dp"
20                 android:layout_height="wrap_content"
21                 android:layout_weight="0.3"
22                 android:gravity="center"
23                 android:textSize="18dp"
24                 android:text="用户名:"/>
25             <EditText
26                 android:id="@+id/name"
27                 android:layout_width="0dp"
28                 android:layout_height="wrap_content"
29                 android:layout_weight="1"
30                 android:layout_marginRight="20dp"/>
31         </LinearLayout>
32 
33         <LinearLayout
34             android:layout_width="match_parent"
35             android:layout_height="wrap_content"
36             android:layout_marginTop="10dp"
37             android:orientation="horizontal">
38             <TextView
39                 android:layout_width="0dp"
40                 android:layout_height="wrap_content"
41                 android:gravity="center"
42                 android:textSize="18dp"
43                 android:layout_weight="0.3"
44                 android:text="密    码:"/>
45             <EditText
46                 android:id="@+id/pwd"
47                 android:layout_width="0dp"
48                 android:layout_height="wrap_content"
49                 android:inputType="textPassword"
50                 android:layout_weight="1"
51                 android:layout_marginRight="20dp"
52                 />
53         </LinearLayout>
54         <LinearLayout
55             android:layout_width="match_parent"
56             android:layout_height="wrap_content"
57             android:orientation="horizontal">
58             <Button
59                 android:id="@+id/login"
60                 android:layout_width="wrap_content"
61                 android:layout_height="wrap_content"
62                 android:layout_weight="1"
63                 android:layout_margin="5dp"
64                 android:text="登录"
65                 />
66             <Button
67                 android:id="@+id/reg"
68                 android:layout_width="wrap_content"
69                 android:layout_height="wrap_content"
70                 android:layout_weight="1"
71                 android:layout_margin="5dp"
72                 android:text="注册"
73                 />
74         </LinearLayout>
75     </LinearLayout>
76 
77 
78 </androidx.constraintlayout.widget.ConstraintLayout>

activity_welcome.xml

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
 3     xmlns:app="http://schemas.android.com/apk/res-auto"
 4     xmlns:tools="http://schemas.android.com/tools"
 5     android:layout_width="match_parent"
 6     android:layout_height="match_parent"
 7     tools:context=".Welcome">
 8     <TextView
 9         android:id="@+id/mainword"
10         android:layout_width="fill_parent"
11         android:layout_height="fill_parent"
12         android:gravity="center"
13         android:textSize="22dp"
14         tools:ignore="MissingConstraints" />
15 </androidx.constraintlayout.widget.ConstraintLayout>

activity_register.xml

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
 3     xmlns:app="http://schemas.android.com/apk/res-auto"
 4     xmlns:tools="http://schemas.android.com/tools"
 5     android:layout_width="match_parent"
 6     android:layout_height="match_parent"
 7     tools:context=".Register">
 8     <LinearLayout
 9         android:layout_width="match_parent"
10         android:layout_height="match_parent"
11         android:orientation="vertical">
12         <!-- 用户名部分 -->
13         <TextView
14             android:layout_width="fill_parent"
15             android:layout_height="wrap_content"
16             android:text="用户名:" />
17 
18         <EditText
19             android:id="@+id/usename"
20             android:layout_width="fill_parent"
21             android:layout_height="wrap_content"
22             android:text=""
23             />
24         <!-- 密码部分 -->
25         <TextView
26             android:layout_width="fill_parent"
27             android:layout_height="wrap_content"
28             android:text="密 码:"
29             />
30 
31         <EditText
32             android:id="@+id/usepwd"
33             android:layout_width="fill_parent"
34             android:layout_height="wrap_content"
35             android:inputType="textPassword"
36 
37             />
38         <!-- 确认密码部分 -->
39         <TextView
40             android:layout_width="fill_parent"
41             android:layout_height="wrap_content"
42             android:text="确认密码:"
43             />
44 
45         <EditText
46             android:id="@+id/usepwd2"
47             android:layout_width="fill_parent"
48             android:layout_height="wrap_content"
49             android:inputType="textPassword"
50             />
51         <Button
52             android:id="@+id/submit"
53             android:layout_width="fill_parent"
54             android:layout_height="wrap_content"
55             android:text="注册" />
56     </LinearLayout>
57 </androidx.constraintlayout.widget.ConstraintLayout>

运行效果截图:

 

posted on 2023-03-01 23:58  樱华旧梦  阅读(16)  评论(0)    收藏  举报