2023年3月13日软工日报
今天是结对作业,也是cp组成之日,我和ixuan组队,ixuan也就是王铭轩,我们要进行组队训练,写地铁查询系统。晚上写了2个半小时代码,代码量200多吧。
代码如下
:
package com.example.denglu; import androidx.appcompat.app.AppCompatActivity; import android.annotation.SuppressLint; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.TextView; import java.util.List; public class jued extends AppCompatActivity implements View.OnClickListener { private EditText et_name1; private EditText et_guan1; private EditText et_zong1; /* private TextView sk;*/ private UserDBHelper0 mHelper; private LinearLayout xs1; @SuppressLint("MissingInflatedId") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_jued); et_name1 = findViewById(R.id.et_name); et_guan1 = findViewById(R.id.et_guan); et_zong1=findViewById(R.id.et_zong); xs1=findViewById(R.id.xs); // sk=findViewById(R.id.list); findViewById(R.id.btn_delete).setOnClickListener(this); findViewById(R.id.btn_update).setOnClickListener(this); findViewById(R.id.btn_query).setOnClickListener(this); } @Override protected void onStart() { super.onStart(); mHelper = UserDBHelper0.getInstance(this); //打开数据库读和写 mHelper.openWriteLink(); mHelper.openReadLink(); } @Override protected void onStop() { super.onStop(); mHelper.closeLInk(); } @Override public void onClick(View view) { String name = et_name1.getText().toString(); String s = et_guan1.getText().toString(); String s1 = et_zong1.getText().toString(); dakai dakai=null; switch (view.getId()) { case R.id.btn_delete: if (mHelper.deleteByName(name) > 0) { ToastUtil.show(this, "删除成功"); } break; case R.id.btn_update: break; case R.id.btn_query: if(name!=null){ List<dakai> list = mHelper.queryByname(name); for (dakai u:list) { TextView sk=new TextView(this); sk.setText(u.toString()); sk.setTextSize(18); xs1.addView(sk); } } if (s!=null){List<dakai> list1 = mHelper.queryByguan(s);} break; } } }
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:padding="5dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="40dp" android:orientation="horizontal"> <TextView android:id="@+id/tv_name" android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="center" android:text="姓名:" android:textColor="@color/black" android:textSize="17sp" /> <EditText android:id="@+id/et_name" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:hint="请输入姓名" android:inputType="text" android:maxLength="12" android:textColor="@color/black" android:textSize="17sp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="40dp" android:orientation="horizontal"> <TextView android:id="@+id/guan" android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="center" android:text="关键字: " android:textColor="@color/black" android:textSize="17sp" /> <EditText android:id="@+id/et_guan" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:hint="请输入关键字" android:maxLength="3" android:textColor="@color/black" android:textSize="17sp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="40dp" android:orientation="horizontal"> <TextView android:id="@+id/tv_zong" android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="center" android:text="每日总结:" android:textColor="@color/black" android:textSize="17sp" /> <EditText android:id="@+id/et_zong" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:hint="请输入总结" android:maxLength="5" android:textColor="@color/black" android:textSize="17sp" /> </LinearLayout> <Button android:id="@+id/btn_query" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="查询" android:textColor="@color/black" android:textSize="17sp" /> <Button android:id="@+id/btn_delete" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="删除" android:textColor="@color/black" android:textSize="17sp" /> <Button android:id="@+id/btn_update" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="修改" android:textColor="@color/black" android:textSize="17sp" /> <LinearLayout android:id="@+id/xs" android:layout_width="match_parent" android:layout_height="match_parent"></LinearLayout> </LinearLayout>
下面是我们cp照片