体温填报(四)
注册页面及代码:
activity_register.xml
<?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=".RegisterActivity"> <LinearLayout android:layout_width="0dp" android:layout_height="0dp" android:orientation="vertical" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.0" android:padding="10dp"> <TextView android:id="@+id/TextView" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="注册界面" android:textSize="22sp" android:textStyle="bold" android:gravity="center"/> <EditText android:id="@+id/et_reg_number" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="30dp" android:ems="10" android:hint="学号" android:maxLines="1" android:inputType="textEmailAddress" android:text="" /> <EditText android:id="@+id/et_reg_id" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:ems="10" android:hint="姓名" android:maxLines="1" android:inputType="textPersonName" android:text="" /> <EditText android:id="@+id/et_reg_password" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:ems="10" android:hint="密码" android:maxLines="1" android:inputType="textPassword" /> <EditText android:id="@+id/et_reg_phone" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:ems="10" android:hint="手机号码" android:maxLines="1" android:inputType="textPersonName" android:text="" /> <RadioButton android:id="@+id/rbtn1" android:layout_width="392dp" android:layout_height="wrap_content" android:text="信1905-1" /> <RadioButton android:id="@+id/rbtn2" android:layout_width="393dp" android:layout_height="wrap_content" android:text="信1905-2" /> <Button android:id="@+id/btn_reg_submit" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/holo_blue_bright" android:textStyle="bold" android:layout_marginTop="30dp" android:onClick="btn_start_register_onclick" android:text="注册" /> </LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout>
RegisterActivity.java
package com.example.tem; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.EditText; public class RegisterActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register); } public void btn_start_register_onclick(View view) { EditText etId=findViewById(R.id.et_reg_id); EditText etNumber=findViewById(R.id.et_reg_number); EditText etPassword=findViewById(R.id.et_reg_password); Intent intent=new Intent(); intent.putExtra("id",etId.getText().toString()); intent.putExtra("number",etNumber.getText().toString()); intent.putExtra("password",etPassword.getText().toString()); setResult(1,intent); finish(); } }