体温填报APP--新增用户

新增用户需要注册用户

填写相关信息

package com.example.tiwen20;

import android.Manifest;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import androidx.appcompat.app.AppCompatActivity;

public class zhuceActivity extends AppCompatActivity implements View.OnClickListener , RadioGroup.OnCheckedChangeListener{
private Button zhuce_bt;
private EditText id_et,name_et,phone_et;
private UserDB userDB;
private RadioGroup classes_rg;
private RadioButton classes1_rb,classes2_rb;
private UserBean userBean;
private Log log;
private Intent intent;
private String id,name,classes,phone;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_zhuce);
id_et = (EditText) findViewById(R.id.et_id);
name_et = (EditText) findViewById(R.id.et_name);
phone_et = (EditText) findViewById(R.id.et_phone);
classes_rg = (RadioGroup) findViewById(R.id.rg_classes);
classes1_rb=(RadioButton)findViewById(R.id.rb_classes1);
classes2_rb=(RadioButton)findViewById(R.id.rb_classes2);
classes_rg.setOnCheckedChangeListener(this);
zhuce_bt = (Button) findViewById(R.id.bt_zhuce);
zhuce_bt.setOnClickListener(this);
userBean =new UserBean();
userDB = new UserDB(this);
}
@Override
public void onClick(View v) {
id=id_et.getText().toString();
name=name_et.getText().toString();
phone=phone_et.getText().toString();
userBean.setClasses(classes);
userBean.setPhone(phone);
userBean.setId(id);
userBean.setName(name);
userDB.insert(userBean);
intent = new Intent(this, MainActivity.class);
intent.putExtra("name",name);
intent.putExtra("classes",classes);
log.v("mylog","这是我的调试信息11111111111111111111111111111");
startActivity(intent);
}

@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId) {
case R.id.rb_classes1:
classes = classes1_rb.getText().toString();
break;
case R.id.rb_classes2:
classes = classes2_rb.getText().toString();
break;
default:
break;
}
}
}
<?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">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1.学号"
android:textSize="25sp"
android:textColor="#000000"
>
</TextView>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/et_id"
android:hint="填写学号">
</EditText>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2.姓名"
android:textSize="25sp"
android:textColor="#000000"
>
</TextView>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/et_name"
android:hint="填写姓名">
</EditText>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3.手机号码"
android:textSize="25sp"
android:textColor="#000000"
>
</TextView>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/et_phone"
android:hint="填写手机号码">
</EditText>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4.班级"
android:textSize="25sp"
android:textColor="#000000"
>
</TextView>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/rg_classes"
>
<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="1905-1"
android:id="@+id/rb_classes1">
</RadioButton>
<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="1905-2"
android:id="@+id/rb_classes2">
</RadioButton>
</RadioGroup>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="注册"
android:id="@+id/bt_zhuce"
android:textSize="25sp">
</Button>
</LinearLayout>


posted @ 2021-03-05 13:58  黄某人233  阅读(89)  评论(0编辑  收藏  举报