我们组整体实力比较弱,都是边学边做。
第一天做了登录注册ui
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
|
package com.example.runapp; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; import com.example.runapp.MainActivity; import com.example.runapp.R; import com.example.runapp.RegisterActivity; public class LoginActivity extends AppCompatActivity { Button btnLogin; EditText editTextName,editTextPwd; TextView textRegister; @Override protected void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R.layout.activity_login); btnLogin= this .findViewById(R.id.buttonLogin); editTextName= this .findViewById(R.id.editTextName); editTextPwd= this .findViewById(R.id.editTextPassword); textRegister= this .findViewById(R.id.textViewRegister); textRegister.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Register(); } }); btnLogin.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Login(); } }); } public void Register() { Intent intent= new Intent(); intent.setClass(LoginActivity. this , RegisterActivity. class ); startActivity(intent); } public void Login() { String editName=editTextName.getText().toString(); String editPwd=editTextPwd.getText().toString(); if (editName.equals( "admit" )&&editPwd.equals( "admit" )) { Toast.makeText( this , "登录成功!" ,Toast.LENGTH_LONG).show(); Intent intent= new Intent(); intent.setClass(LoginActivity. this , MainActivity. class ); startActivity(intent); } else { Toast.makeText( this , "登录失败!" ,Toast.LENGTH_LONG).show(); } } } |
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
|
package com.example.runapp; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; public class SplashActivity extends AppCompatActivity { Button btngo; @Override protected void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R.layout.activity_splash); btngo= this .findViewById(R.id.buttongo); btngo.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent intent= new Intent(); intent.setClass(SplashActivity. this , LoginActivity. class ); startActivity(intent); } }); } } |
<?xml version="1.0" encoding="utf-8"?> <FrameLayout 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=".SplashActivity"> <ImageView android:id="@+id/imageView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:scaleType="centerCrop" app:srcCompat="@drawable/run_splash" tools:layout_editor_absoluteX="0dp" tools:layout_editor_absoluteY="-16dp" /> <TextView android:id="@+id/textView8" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal|bottom" android:layout_marginBottom="100dp" android:text="加油,奥利给!" android:textSize="20sp" android:textColor="@color/black" /> <Button android:id="@+id/buttongo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal|bottom" android:text="点击进入" android:background="#f83"/> </FrameLayout>
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout 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:layout_margin="5dp" tools:context=".RegisterActivity"> <ImageView android:id="@+id/imageView2" android:layout_width="wrap_content" android:layout_height="200dp" app:srcCompat="@drawable/user_reg" /> <TextView android:id="@+id/textView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:layout_marginLeft="35dp" android:layout_below="@id/imageView2" android:text="账号" /> <EditText android:id="@+id/editTextName" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_marginLeft="35dp" android:layout_marginRight="35dp" android:layout_marginTop="10dp" android:layout_below="@id/textView3" /> <TextView android:id="@+id/textView4" android:layout_marginTop="10dp" android:layout_marginLeft="35dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/editTextName" android:text="密码" /> <EditText android:id="@+id/editTextPassword" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/textView4" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_marginLeft="35dp" android:layout_marginRight="35dp" android:layout_marginTop="10dp" android:ems="10" android:inputType="textPassword" /> <TextView android:id="@+id/textView6" android:layout_marginTop="10dp" android:layout_marginLeft="35dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/editTextPassword" android:text="确认密码" /> <EditText android:id="@+id/editTextNoPassword" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_marginLeft="35dp" android:layout_marginRight="35dp" android:layout_marginTop="10dp" android:ems="10" android:layout_below="@id/textView6" android:inputType="textPassword" /> <TextView android:id="@+id/textView7" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:layout_marginLeft="35dp" android:layout_below="@id/editTextNoPassword" android:text="密码提示" /> <EditText android:id="@+id/editTextWarn" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_marginLeft="35dp" android:layout_marginRight="35dp" android:layout_marginTop="10dp" android:layout_below="@id/textView7" /> <Button android:id="@+id/buttonRegister" android:layout_width="200dp" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginBottom="50dp" android:background="#f83" android:text="注册" /> </RelativeLayout>