體溫填報(三)
阿新 • • 發佈:2021-06-21
登入頁面及程式碼:
activity_signin.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=".SigninActivity"> <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_signin_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_signin_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" /> <Button android:id="@+id/btn_signin_submit" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/holo_blue_bright" android:textStyle="bold" android:onClick="btn_start_siginin_onclick" android:layout_marginTop="30dp" android:text="登入" /> </LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout>
SigninActivity.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 SigninActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_signin); } public void btn_start_siginin_onclick(View view) { EditText etId=findViewById(R.id.et_signin_id); EditText etPassword=findViewById(R.id.et_signin_password); Intent intent=new Intent(); intent.putExtra("id",etId.getText().toString()); intent.putExtra("password",etPassword.getText().toString()); setResult(0,intent); finish(); } }