软件工程日报十九——第一次个人作业 每日打卡APP的实现
今天,我们验收了几周前的第一次个人作业——每日打卡App,在这两天的完善和修改下,终于完成了本次作业的验收,下面是有关本次作业的情况
项目要求:
1、用户注册:用户注册信息包括用户ID(学号)、用户名(姓名),手机号码,用户单位(班级),用户班级四项基本信息,用户第一次注册后,用户姓名不用每次输入 。
2、每日总结打卡:内容包括:日期、每日关键字、每日总结、坚持天数(自动计数,显示上次天数)、连续最长天数。
3、每日提醒记事本:设置每日事件闹钟,可以提醒用户每日必做事件。
4、当天数据存储到本地数据库,其余数据存储到远程服务器上。
5、汇总统计:教师可以查询统计所有同学的每日打卡记录。
6、每日总结查询:可以按照关键字、每日总结查询。
7、自动从数据库中生成所有人的每日总结记录,包括序号、班级、学号、姓名、发表总次数。
项目源码:
MainActivity.java
package com.example.test06; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.content.SharedPreferences; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends AppCompatActivity { EditText name,pwd; Button btnlogin,btnreg,teacher; Mysql mysql; SQLiteDatabase db; SharedPreferences sp1,sp2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); name = this.findViewById(R.id.name); //用户名输入框 pwd = this.findViewById(R.id.pwd); //密码输入框 btnlogin = this.findViewById(R.id.login); //登录按钮 btnreg = this.findViewById(R.id.reg); //注册按钮 teacher=this.findViewById(R.id.teacher); sp1 = this.getSharedPreferences("userinfo",this.MODE_PRIVATE); sp2 = this.getSharedPreferences("username",this.MODE_PRIVATE); name.setText(sp1.getString("usname",null)); pwd.setText(sp1.getString("uspwd",null)); mysql = new Mysql(this,"Userinfo",null,1); //建数据库或者取数据库 db = mysql.getReadableDatabase(); btnlogin.setOnClickListener(new View.OnClickListener() { //登录事件 @Override public void onClick(View v) { String username = name.getText().toString(); String password = pwd.getText().toString(); //获取用户输入的用户名和密码 //查询用户名和密码相同的数据 Cursor cursor = db.query("logins",new String[]{"usname","uspwd"}," usname=? and uspwd=?",new String[]{username,password},null,null,null); int flag = cursor.getCount(); //查询出来的记录项的条数,若没有该用户则为0条 if(flag!=0){ //若查询出的记录不为0,则进行跳转操作 Intent intent = new Intent(); intent.setClass(MainActivity.this,add.class); //设置页面跳转 SharedPreferences.Editor editor = sp2.edit(); cursor.moveToFirst(); //将光标移动到position为0的位置,默认位置为-1 String loginname = cursor.getString(0); editor.putString("Loginname",loginname); editor.commit(); //将用户名存到SharedPreferences中 startActivity(intent); } else{ Toast.makeText(MainActivity.this,"用户名或密码错误!",Toast.LENGTH_LONG).show(); //提示用户信息错误或没有账号 } } }); btnreg.setOnClickListener(new View.OnClickListener() { //注册事件 @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(MainActivity.this,Register.class); //跳转到注册页面 startActivity(intent); Toast.makeText(MainActivity.this,"前往注册!",Toast.LENGTH_SHORT).show(); } }); teacher.setOnClickListener(new View.OnClickListener() { //注册事件 @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(MainActivity.this,teacher.class); //跳转到注册页面 startActivity(intent); Toast.makeText(MainActivity.this,"教师登录!",Toast.LENGTH_SHORT).show(); } }); } }
Mysql.java
package com.example.test06; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import androidx.annotation.Nullable; public class Mysql extends SQLiteOpenHelper { public Mysql(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) { super(context, name, factory, version); } @Override public void onCreate(SQLiteDatabase db) { db.execSQL( "create table logins (id integer primary key autoincrement,usname text,uspwd text,id1 text,cphone text,lass1 text)"); db.execSQL("create table adda (id integer primary key autoincrement,date text,title text,zongjie text)"); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { } }
Register.java
package com.example.test06; import androidx.appcompat.app.AppCompatActivity; import android.content.ContentValues; import android.content.Intent; import android.content.SharedPreferences; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class Register extends AppCompatActivity { EditText usename,usepwd,usepwd2,id1,lass1,cphone; Button submit,back; Mysql mysql1; SQLiteDatabase db; SharedPreferences sp; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register); id1= this.findViewById(R.id.id1); lass1 = this.findViewById(R.id.lass1); cphone = this.findViewById(R.id.cphone); usename = this.findViewById(R.id.usename); usepwd = this.findViewById(R.id.usepwd); usepwd2 = this.findViewById(R.id.usepwd2); submit = this.findViewById(R.id.submit); back=this.findViewById(R.id.back); mysql1 = new Mysql(this,"Userinfo",null,1); //建数据库 db = mysql1.getReadableDatabase(); sp = this.getSharedPreferences("userinfo",this.MODE_PRIVATE); submit.setOnClickListener(new View.OnClickListener() { boolean flag = true; //判断用户是否已存在的标志位 @Override public void onClick(View v) { String ID1 = id1.getText().toString(); String phone1 = cphone.getText().toString(); String lass2 = lass1.getText().toString(); String name = usename.getText().toString(); //用户名 String pwd01 = usepwd.getText().toString(); //密码 String pwd02 = usepwd2.getText().toString(); //二次输入的密码 if(name.equals("")||pwd01 .equals("")||pwd02.equals("")){ Toast.makeText(Register.this, "用户名或密码不能为空!!", Toast.LENGTH_LONG).show(); } else{ Cursor cursor = db.query("logins",new String[]{"usname"},null,null,null,null,null); while (cursor.moveToNext()){ if(cursor.getString(0).equals(name)){ flag = false; break; } } if(flag==true){ //判断用户是否已存在 if (pwd01.equals(pwd02)) { //判断两次输入的密码是否一致,若一致则继续,不一致则提醒密码不一致 ContentValues cv = new ContentValues(); cv.put("usname",name); cv.put("uspwd",pwd01); cv.put("id1",ID1); cv.put("cphone",phone1); cv.put("lass1",lass2); db.insert("logins",null,cv); SharedPreferences.Editor editor = sp.edit(); editor.putString("usname",name); editor.putString("uspwd",pwd01); editor.putString("id1",ID1); editor.putString("cphone",phone1); editor.putString("lass1",lass2); editor.commit(); Intent intent = new Intent(); intent.setClass(Register.this,MainActivity.class); //跳转到登录页面 startActivity(intent); Toast.makeText(Register.this, "注册成功!", Toast.LENGTH_LONG).show(); } else { Toast.makeText(Register.this, "密码不一致!", Toast.LENGTH_LONG).show(); //提示密码不一致 } } else{ Toast.makeText(Register.this, "用户已存在!", Toast.LENGTH_LONG).show(); //提示密码不一致 } } } }); back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(Register.this,MainActivity.class); startActivity(intent); Toast.makeText(Register.this,"返回",Toast.LENGTH_SHORT).show(); } }); } }
add.java
package com.example.test06; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; public class add extends AppCompatActivity { Button add,back; Button clock,query; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.add1); add = this.findViewById(R.id.add); clock=this.findViewById(R.id.clock); query=this.findViewById(R.id.query); back=this.findViewById(R.id.back); add.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(add.this,addData.class); startActivity(intent); Toast.makeText(add.this,"添加数据!",Toast.LENGTH_SHORT).show(); } }); clock.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(add.this,ClockActivity.class); startActivity(intent); Toast.makeText(add.this,"设置闹钟",Toast.LENGTH_SHORT).show(); } }); query.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(add.this,queryActivity.class); startActivity(intent); Toast.makeText(add.this,"查询数据",Toast.LENGTH_SHORT).show(); } }); back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(add.this,MainActivity.class); startActivity(intent); Toast.makeText(add.this,"返回",Toast.LENGTH_SHORT).show(); } }); } }
addData.java
package com.example.test06; import androidx.appcompat.app.AppCompatActivity; import android.content.ContentValues; import android.content.Intent; import android.content.SharedPreferences; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class addData extends AppCompatActivity { EditText date,title,zongjie; Button submit,back; Mysql mysql; SQLiteDatabase db; SharedPreferences sp; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.add); date = this.findViewById(R.id.date); title = this.findViewById(R.id.title); zongjie = this.findViewById(R.id.zongjie); submit = this.findViewById(R.id.submit); back=this.findViewById(R.id.back); mysql = new Mysql(addData.this,"addate",null,2); //建数据库 db = mysql.getReadableDatabase(); sp = this.getSharedPreferences("addate",this.MODE_PRIVATE); submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String date1 = date.getText().toString(); String title1 = title.getText().toString(); String zongjie1 = zongjie.getText().toString(); if(date1.equals("")||title1 .equals("")||zongjie1.equals("")){ Toast.makeText(addData.this, "提交内容不能为空!!", Toast.LENGTH_LONG).show(); } else{ Cursor cursor1=db.rawQuery("select * from adda",new String[]{}); int i=cursor1.getCount(); cursor1.close(); ContentValues cv = new ContentValues(); cv.put("date",date1); cv.put("title",title1); cv.put("zongjie",zongjie1); db.insert("adda",null,cv); SharedPreferences.Editor editor = sp.edit(); editor.putString("date",date1); editor.putString("title",title1); editor.putString("zongjie",zongjie1); editor.commit(); Intent intent = new Intent(); intent.setClass(addData.this,add.class); startActivity(intent); Toast.makeText(addData.this, "添加成功!您已经坚持"+i+"天", Toast.LENGTH_LONG).show(); } } }); back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(addData.this,add.class); startActivity(intent); Toast.makeText(addData.this,"返回",Toast.LENGTH_SHORT).show(); } }); } }
ClockActivity
package com.example.test06; import android.app.Activity; import android.app.AlarmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TimePicker; import android.widget.Toast; import androidx.annotation.Nullable; import java.util.Calendar; public class ClockActivity extends Activity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.clock); final TimePicker timePicker =(TimePicker) findViewById(R.id.time); timePicker.setIs24HourView(true); Button button1=(Button) findViewById(R.id.set); //为设置闹钟按钮添加事件监听器 button1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //设置闹钟 Intent intent=new Intent(ClockActivity.this,AlarmActivity.class);//创建一个Intent对象 PendingIntent pendingIntent=PendingIntent.getActivity(ClockActivity.this,0,intent,PendingIntent.FLAG_MUTABLE);//获取显示闹钟的对象 AlarmManager alarm=(AlarmManager) getSystemService(Context.ALARM_SERVICE);//获取alarmManager对象 Calendar c=Calendar.getInstance();//获取日历对象 c.set(Calendar.HOUR_OF_DAY,timePicker.getCurrentHour());//设置闹钟小时数 c.set(Calendar.MINUTE,timePicker.getCurrentMinute());//设置闹钟分钟数 c.set(Calendar.SECOND,0);//设置闹钟秒数 alarm.set(AlarmManager.RTC_WAKEUP,c.getTimeInMillis(),pendingIntent);//设置一个闹钟 Toast.makeText(ClockActivity.this,"闹钟设置成功",Toast.LENGTH_SHORT).show(); } }); } }
AlarmActivity.java
package com.example.test06; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.widget.Toast; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; public class AlarmActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); AlertDialog alert=new AlertDialog.Builder(this).create(); //alert.setIcon(R.drawable.alarm); alert.setTitle("时间到了"); alert.setMessage("需要干活了"); alert.setButton(DialogInterface.BUTTON_POSITIVE, "确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(); intent.setClass(AlarmActivity.this,add.class); startActivity(intent); Toast.makeText(AlarmActivity.this,"干活",Toast.LENGTH_SHORT).show(); } }); alert.show(); } }
queryActivity.java
package com.example.test06; import android.content.Intent; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.provider.ContactsContract; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; import java.util.ArrayList; import java.util.List; public class queryActivity extends AppCompatActivity { EditText querydata; TextView show1,show2,show3; Button submit,back; Mysql mysql; SQLiteDatabase db; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.query); querydata = this.findViewById(R.id.querydata); submit = this.findViewById(R.id.submit); back=this.findViewById(R.id.back); mysql = new Mysql(this,"addate",null,2); //建数据库 db = mysql.getReadableDatabase(); show1=findViewById(R.id.show1); show2=findViewById(R.id.show2); show3=findViewById(R.id.show3); submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String title = querydata.getText().toString(); show1.setText("日期"); show2.setText("关键字"); show3.setText("总结"); Cursor cursor1 = db.rawQuery("select * from adda where title = ? or zongjie = ?", new String[]{title,title}); while (cursor1.moveToNext()) { String date = cursor1.getString(1); String title1 = cursor1.getString(2); String number = cursor1.getString(3); show1.setText(show1.getText()+"\n"+date); show2.setText(show2.getText()+"\n"+title1); show3.setText(show3.getText()+"\n"+number); } cursor1.close(); db.close(); } }); back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(queryActivity.this,add.class); startActivity(intent); Toast.makeText(queryActivity.this,"返回",Toast.LENGTH_SHORT).show(); } }); } }
teacher.java
package com.example.test06; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; public class teacher extends AppCompatActivity { Button query1,query2,back; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.teacher); query1=this.findViewById(R.id.query1); query2=this.findViewById(R.id.query2); back=this.findViewById(R.id.back); query1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(teacher.this,totalQuery.class); startActivity(intent); Toast.makeText(teacher.this,"汇总查询!",Toast.LENGTH_SHORT).show(); } }); query2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(teacher.this,queryActivity.class); startActivity(intent); Toast.makeText(teacher.this,"关键字查询!",Toast.LENGTH_SHORT).show(); } }); back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(teacher.this,MainActivity.class); startActivity(intent); Toast.makeText(teacher.this,"返回",Toast.LENGTH_SHORT).show(); } }); } }
totalQuery.java
package com.example.test06; import android.content.Intent; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.provider.ContactsContract; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; import java.util.ArrayList; import java.util.List; public class totalQuery extends AppCompatActivity { TextView show1,show2,show3; Button submit,back; Mysql mysql; SQLiteDatabase db; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.totalquery); submit = this.findViewById(R.id.submit); back=this.findViewById(R.id.back); mysql = new Mysql(this,"addate",null,2); //建数据库 db = mysql.getReadableDatabase(); show1=findViewById(R.id.show1); show2=findViewById(R.id.show2); show3=findViewById(R.id.show3); submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { show1.setText("日期"); show2.setText("关键字"); show3.setText("总结"); Cursor cursor1 = db.rawQuery("select * from adda ", new String[]{}); while (cursor1.moveToNext()) { String date = cursor1.getString(1); String title1 = cursor1.getString(2); String number = cursor1.getString(3); show1.setText(show1.getText()+"\n"+date); show2.setText(show2.getText()+"\n"+title1); show3.setText(show3.getText()+"\n"+number); } cursor1.close(); db.close(); } }); back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(totalQuery.this,teacher.class); startActivity(intent); Toast.makeText(totalQuery.this,"返回",Toast.LENGTH_SHORT).show(); } }); } }
activity_main.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=".MainActivity"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:orientation="horizontal"> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.3" android:gravity="center" android:textSize="18dp" android:text="用户名:"/> <EditText android:id="@+id/name" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:layout_marginRight="20dp"/> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:orientation="horizontal"> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:gravity="center" android:textSize="18dp" android:layout_weight="0.3" android:text="密 码:"/> <EditText android:id="@+id/pwd" android:layout_width="0dp" android:layout_height="wrap_content" android:inputType="textPassword" android:layout_weight="1" android:layout_marginRight="20dp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/login" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:layout_margin="5dp" android:text="登录" /> <Button android:id="@+id/reg" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:layout_margin="5dp" android:text="注册" /> </LinearLayout> <Button android:id="@+id/teacher" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5dp" android:text="教师登录" /> </LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout>
activity_register.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout 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=".Register"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="学号:" ></TextView> <EditText android:id="@+id/id1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text=""> </EditText> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="手机号:" /> <EditText android:id="@+id/cphone" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text=""> </EditText> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="班级:" /> <EditText android:id="@+id/lass1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text=""> </EditText> <!-- 用户名部分 --> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="用户名:" /> <EditText android:id="@+id/usename" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text=""> </EditText> <!-- 密码部分 --> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="密 码:" /> <EditText android:id="@+id/usepwd" android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="textPassword" /> <!-- 确认密码部分 --> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="确认密码:" /> <EditText android:id="@+id/usepwd2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="textPassword" /> <Button android:id="@+id/submit" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="注册" /> <Button android:id="@+id/back" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5dp" android:text="返回" /> </LinearLayout> </LinearLayout>
add.xml
<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".addData"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:layout_editor_absoluteX="135dp" tools:layout_editor_absoluteY="342dp"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="日期" > </TextView> <EditText android:id="@+id/date" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="关键字:" /> <EditText android:id="@+id/title" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="每日总结:" /> <EditText android:id="@+id/zongjie" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text" /> <Button android:id="@+id/submit" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="提交" /> <Button android:id="@+id/back" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5dp" android:text="返回" /> </LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout>
add1.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".add"> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/add" android:text="添加数据" android:textColor="@color/white"> </Button> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/clock" android:text="设置闹钟" android:textColor="@color/white"> </Button> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/query" android:text="查询数据" android:textColor="@color/white"> </Button> <Button android:id="@+id/back" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5dp" android:text="返回" /> </LinearLayout>
clock.xml
<?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" tools:context=".AlarmActivity"> <TimePicker android:id="@+id/time" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <Button android:id="@+id/set" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:text="设置闹钟" /> </RelativeLayout>
query.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".queryActivity"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="查询" android:id="@+id/title" android:textSize="30sp" android:textColor="@color/white" android:background="#E91E63" android:gravity="center"> </TextView> <LinearLayout android:layout_below="@+id/title" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:layout_editor_absoluteX="135dp" tools:layout_editor_absoluteY="342dp"> <TextView android:layout_width="match_parent" android:layout_height="70dp" android:id="@+id/a" android:text="请输入关键字或者每日总结" android:textSize="20dp" /> <EditText android:id="@+id/querydata" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text" ></EditText> <Button android:id="@+id/submit" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="确定" /> <Button android:id="@+id/back" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5dp" android:text="返回" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:textSize="18dp" android:id="@+id/show1"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:textSize="18dp" android:id="@+id/show2"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:textSize="18dp" android:id="@+id/show3"/> </LinearLayout> </LinearLayout> </RelativeLayout>
teacher.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".add"> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/query1" android:text="汇总查询" android:textColor="@color/white"> </Button> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/query2" android:text="条件查询" android:textColor="@color/white"> </Button> <Button android:id="@+id/back" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5dp" android:text="返回" /> </LinearLayout>
totalquery.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".queryActivity"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="查询" android:id="@+id/title" android:textSize="30sp" android:textColor="@color/white" android:background="#E91E63" android:gravity="center"> </TextView> <LinearLayout android:layout_below="@+id/title" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:layout_editor_absoluteX="135dp" tools:layout_editor_absoluteY="342dp"> <Button android:layout_below="@+id/title" android:id="@+id/submit" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="确定查询" > </Button> <Button android:id="@+id/back" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5dp" android:text="返回" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:textSize="18dp" android:id="@+id/show1"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:textSize="18dp" android:id="@+id/show2"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:textSize="18dp" android:id="@+id/show3"/> </LinearLayout> </LinearLayout> </RelativeLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"> <application android:allowBackup="true" android:dataExtractionRules="@xml/data_extraction_rules" android:fullBackupContent="@xml/backup_rules" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/Theme.Test06" tools:targetApi="31"> <activity android:name=".MainActivity" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.example.test06.addData" /> <activity android:name="com.example.test06.Register" /> <activity android:name="com.example.test06.add" /> <activity android:name="com.example.test06.ClockActivity" /> <activity android:name="com.example.test06.AlarmActivity" /> <activity android:name="com.example.test06.queryActivity" /> <activity android:name="com.example.test06.teacher" /> <activity android:name="com.example.test06.totalQuery" /> </application> </manifest>