diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..b589d56
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..28e2a16
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..1b16719
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..70c178a
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index b72362b..64e7ee6 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,2 @@
# HomeCaicaitong
安卓小项目-家庭收支便签
-11
\ No newline at end of file
diff --git a/app/.gitignore b/app/.gitignore
new file mode 100644
index 0000000..42afabf
--- /dev/null
+++ b/app/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
new file mode 100644
index 0000000..6bc36b9
--- /dev/null
+++ b/app/build.gradle
@@ -0,0 +1,44 @@
+plugins {
+ id 'com.android.application'
+}
+
+android {
+ compileSdk 31
+
+ defaultConfig {
+ applicationId "com.example.homecaicaitong"
+ minSdk 21
+ targetSdk 31
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+ buildFeatures {
+ viewBinding true
+ }
+}
+
+dependencies {
+
+ implementation 'androidx.appcompat:appcompat:1.2.0'
+ implementation 'com.google.android.material:material:1.3.0'
+ implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
+ implementation 'androidx.annotation:annotation:1.2.0'
+ implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
+ implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
+ testImplementation 'junit:junit:4.13.2'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.2'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
+}
\ No newline at end of file
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
new file mode 100644
index 0000000..481bb43
--- /dev/null
+++ b/app/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/app/src/androidTest/java/com/example/homecaicaitong/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/example/homecaicaitong/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..f6908ce
--- /dev/null
+++ b/app/src/androidTest/java/com/example/homecaicaitong/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package com.example.homecaicaitong;
+
+import android.content.Context;
+
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+ assertEquals("com.example.homecaicaitong", appContext.getPackageName());
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..087d68e
--- /dev/null
+++ b/app/src/main/AndroidManifest.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/example/homecaicaitong/Accountflag.java b/app/src/main/java/com/example/homecaicaitong/Accountflag.java
new file mode 100644
index 0000000..674a66d
--- /dev/null
+++ b/app/src/main/java/com/example/homecaicaitong/Accountflag.java
@@ -0,0 +1,50 @@
+package com.example.homecaicaitong;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.Toast;
+
+import com.example.homecaicaitong.dao.FlagDAO;
+import com.example.homecaicaitong.model.Tb_flag;
+
+public class Accountflag extends AppCompatActivity {
+ private EditText txtFlag;
+ private Button btnflagSaveButton;// ????Button???????
+ private Button btnflagCancelButton;// ????Button???????
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.accountflag);
+
+ txtFlag = (EditText) findViewById(R.id.txtFlag);// ???????????
+ btnflagSaveButton = (Button) findViewById(R.id.btnflagSave);// ??????水?
+ btnflagCancelButton = (Button) findViewById(R.id.btnflagCancel);// ?????????
+ btnflagSaveButton.setOnClickListener(new View.OnClickListener() {// ????水????ü??????
+ @Override
+ public void onClick(View arg0) {
+ String strFlag = txtFlag.getText().toString();// ?????????????
+ if (!strFlag.isEmpty()) {// ?ж???????????
+ FlagDAO flagDAO = new FlagDAO(Accountflag.this);// ????FlagDAO????
+ Tb_flag tb_flag = new Tb_flag(flagDAO.getMaxId() + 1, strFlag);// ????Tb_flag????
+ flagDAO.add(tb_flag);// ????????
+ // ??????????
+ Toast.makeText(Accountflag.this, "??????????????????????", Toast.LENGTH_SHORT).show();
+ } else {
+ Toast.makeText(Accountflag.this, "??????????", Toast.LENGTH_SHORT).show();
+ }
+ }
+ });
+
+ btnflagCancelButton.setOnClickListener(new View.OnClickListener() {// ??????????ü??????
+ @Override
+ public void onClick(View arg0) {
+ txtFlag.setText("");// ??????????
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/homecaicaitong/AddInaccount.java b/app/src/main/java/com/example/homecaicaitong/AddInaccount.java
new file mode 100644
index 0000000..065141e
--- /dev/null
+++ b/app/src/main/java/com/example/homecaicaitong/AddInaccount.java
@@ -0,0 +1,113 @@
+package com.example.homecaicaitong;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.app.DatePickerDialog;
+import android.app.Dialog;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.DatePicker;
+import android.widget.EditText;
+import android.widget.Spinner;
+import android.widget.Toast;
+
+import com.example.homecaicaitong.dao.InaccountDAO;
+import com.example.homecaicaitong.model.Tb_inaccount;
+
+import java.util.Calendar;
+
+public class AddInaccount extends AppCompatActivity {
+ private static final int DATE_DIALOG_ID = 0;// 创建日期对话框常量
+ private EditText txtInMoney, txtInTime, txtInHandler, txtInMark;// 创建4个EditText对象
+ private Spinner spInType;// 创建Spinner对象
+ private Button btnInSaveButton;// 创建Button对象“保存”
+ private Button btnInCancelButton;// 创建Button对象“取消”
+
+ private int mYear;// 年
+ private int mMonth;// 月
+ private int mDay;// 日
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.addinaccount);// 设置布局文件
+ txtInMoney = (EditText) findViewById(R.id.txtInMoney);// 获取金额文本框
+ txtInTime = (EditText) findViewById(R.id.txtInTime);// 获取时间文本框
+ txtInHandler = (EditText) findViewById(R.id.txtInHandler);// 获取付款方文本框
+ txtInMark = (EditText) findViewById(R.id.txtInMark);// 获取备注文本框
+ spInType = (Spinner) findViewById(R.id.spInType);// 获取类别下拉列表
+ btnInSaveButton = (Button) findViewById(R.id.btnInSave);// 获取保存按钮
+ btnInCancelButton = (Button) findViewById(R.id.btnInCancel);// 获取取消按钮
+
+ txtInTime.setOnClickListener(new View.OnClickListener() {// 为时间文本框设置单击监听事件
+ @Override
+ public void onClick(View arg0) {
+ showDialog(DATE_DIALOG_ID);// 显示日期选择对话框
+ }
+ });
+
+ btnInSaveButton.setOnClickListener(new View.OnClickListener() {// 为保存按钮设置监听事件
+ @Override
+ public void onClick(View arg0) {
+ String strInMoney = txtInMoney.getText().toString();// 获取金额文本框的值
+ if (!strInMoney.isEmpty()) {// 判断金额不为空
+ // 创建InaccountDAO对象
+ InaccountDAO inaccountDAO = new InaccountDAO(AddInaccount.this);
+ // 创建Tb_inaccount对象
+ Tb_inaccount tb_inaccount = new Tb_inaccount(inaccountDAO.getMaxId() + 1, Double.parseDouble(strInMoney), txtInTime.getText()
+ .toString(), spInType.getSelectedItem().toString(), txtInHandler.getText().toString(), txtInMark.getText().toString());
+ inaccountDAO.add(tb_inaccount);// 添加收入信息
+ // 弹出信息提示
+ Toast.makeText(AddInaccount.this, "〖新增收入〗数据添加成功!", Toast.LENGTH_SHORT).show();
+ } else {
+ Toast.makeText(AddInaccount.this, "请输入收入金额!", Toast.LENGTH_SHORT).show();
+ }
+ }
+ });
+
+ btnInCancelButton.setOnClickListener(new View.OnClickListener() {// 为取消按钮设置监听事件
+ @Override
+ public void onClick(View arg0) {
+ txtInMoney.setText("");// 设置金额文本框为空
+ txtInMoney.setHint("0.00");// 为金额文本框设置提示
+ txtInTime.setText("");// 设置时间文本框为空
+ txtInTime.setHint("2011-01-01");// 为时间文本框设置提示
+ txtInHandler.setText("");// 设置付款方文本框为空
+ txtInMark.setText("");// 设置备注文本框为空
+ spInType.setSelection(0);// 设置类别下拉列表默认选择第一项
+ }
+ });
+
+ final Calendar c = Calendar.getInstance();// 获取当前系统日期
+ mYear = c.get(Calendar.YEAR);// 获取年份
+ mMonth = c.get(Calendar.MONTH);// 获取月份
+ mDay = c.get(Calendar.DAY_OF_MONTH);// 获取天数
+
+ updateDisplay();// 显示当前系统时间
+ }
+
+ @Override
+ protected Dialog onCreateDialog(int id) {// 重写onCreateDialog方法
+
+ switch (id) {
+ case DATE_DIALOG_ID:// 弹出日期选择对话框
+ return new DatePickerDialog(this, mDateSetListener, mYear, mMonth, mDay);
+ }
+ return null;
+ }
+
+ private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() {
+ public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
+ mYear = year;// 为年份赋值
+ mMonth = monthOfYear;// 为月份赋值
+ mDay = dayOfMonth;// 为天赋值
+ updateDisplay();// 显示设置的日期
+ }
+ };
+
+ private void updateDisplay() {
+ // 显示设置的时间
+ txtInTime.setText(new StringBuilder().append(mYear).append("-").append(mMonth + 1).append("-").append(mDay));
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/homecaicaitong/AddOutaccount.java b/app/src/main/java/com/example/homecaicaitong/AddOutaccount.java
new file mode 100644
index 0000000..a42f70a
--- /dev/null
+++ b/app/src/main/java/com/example/homecaicaitong/AddOutaccount.java
@@ -0,0 +1,116 @@
+package com.example.homecaicaitong;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.app.DatePickerDialog;
+import android.app.Dialog;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.DatePicker;
+import android.widget.EditText;
+import android.widget.Spinner;
+import android.widget.Toast;
+
+import com.example.homecaicaitong.dao.OutaccountDAO;
+import com.example.homecaicaitong.model.Tb_outaccount;
+
+import java.util.Calendar;
+
+public class AddOutaccount extends AppCompatActivity {
+ protected static final int DATE_DIALOG_ID = 0;// 创建日期对话框常量
+ EditText txtMoney, txtTime, txtAddress, txtMark;// 创建4个EditText对象
+ Spinner spType;// 创建Spinner对象
+ Button btnSaveButton;// 创建Button对象“保存”
+ Button btnCancelButton;// 创建Button对象“取消”
+
+ private int mYear;// 年
+ private int mMonth;// 月
+ private int mDay;// 日
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.addoutaccount);// 设置布局文件
+ txtMoney = (EditText) findViewById(R.id.txtMoney);// 获取金额文本框
+ txtTime = (EditText) findViewById(R.id.txtTime);// 获取时间文本框
+ txtAddress = (EditText) findViewById(R.id.txtAddress);// 获取地点文本框
+ txtMark = (EditText) findViewById(R.id.txtMark);// 获取备注文本框
+ spType = (Spinner) findViewById(R.id.spType);// 获取类别下拉列表
+ btnSaveButton = (Button) findViewById(R.id.btnSave);// 获取保存按钮
+ btnCancelButton = (Button) findViewById(R.id.btnCancel);// 获取取消按钮
+
+ txtTime.setOnClickListener(new View.OnClickListener() {// 为时间文本框设置单击监听事件
+
+ @Override
+ public void onClick(View arg0) {
+ showDialog(DATE_DIALOG_ID);// 显示日期选择对话框
+ }
+ });
+
+ btnSaveButton.setOnClickListener(new View.OnClickListener() {// 为保存按钮设置监听事件
+
+ @Override
+ public void onClick(View arg0) {
+ String strMoney = txtMoney.getText().toString();// 获取金额文本框的值
+ if (!strMoney.isEmpty()) {// 判断金额不为空
+ // 创建OutaccountDAO对象
+ OutaccountDAO outaccountDAO = new OutaccountDAO(AddOutaccount.this);
+ // 创建Tb_outaccount对象
+ Tb_outaccount tb_outaccount = new Tb_outaccount(outaccountDAO.getMaxId() + 1, Double.parseDouble(strMoney), txtTime.getText()
+ .toString(), spType.getSelectedItem().toString(), txtAddress.getText().toString(), txtMark.getText().toString());
+ outaccountDAO.add(tb_outaccount);// 添加支出信息
+ // 弹出信息提示
+ Toast.makeText(AddOutaccount.this, "〖新增支出〗数据添加成功!", Toast.LENGTH_SHORT).show();
+ } else {
+ Toast.makeText(AddOutaccount.this, "请输入支出金额!", Toast.LENGTH_SHORT).show();
+ }
+ }
+ });
+
+ btnCancelButton.setOnClickListener(new View.OnClickListener() {// 为取消按钮设置监听事件
+
+ @Override
+ public void onClick(View arg0) {
+ txtMoney.setText("");// 设置金额文本框为空
+ txtMoney.setHint("0.00");// 为金额文本框设置提示
+ txtTime.setText("");// 设置时间文本框为空
+ txtTime.setHint("2011-01-01");// 为时间文本框设置提示
+ txtAddress.setText("");// 设置地点文本框为空
+ txtMark.setText("");// 设置备注文本框为空
+ spType.setSelection(0);// 设置类别下拉列表默认选择第一项
+ }
+ });
+
+ final Calendar c = Calendar.getInstance();// 获取当前系统日期
+ mYear = c.get(Calendar.YEAR);// 获取年份
+ mMonth = c.get(Calendar.MONTH);// 获取月份
+ mDay = c.get(Calendar.DAY_OF_MONTH);// 获取天数
+
+ updateDisplay();// 显示当前系统时间
+ }
+
+ @Override
+ protected Dialog onCreateDialog(int id) {// 重写onCreateDialog方法
+
+ switch (id) {
+ case DATE_DIALOG_ID:// 弹出日期选择对话框
+ return new DatePickerDialog(this, mDateSetListener, mYear, mMonth, mDay);
+ }
+ return null;
+ }
+
+ private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() {
+ public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
+ mYear = year;// 为年份赋值
+ mMonth = monthOfYear;// 为月份赋值
+ mDay = dayOfMonth;// 为天赋值
+ updateDisplay();// 显示设置的日期
+ }
+ };
+
+ private void updateDisplay() {
+ // 显示设置的时间
+ txtTime.setText(new StringBuilder().append(mYear).append("-").append(mMonth + 1).append("-").append(mDay));
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/homecaicaitong/FlagManage.java b/app/src/main/java/com/example/homecaicaitong/FlagManage.java
new file mode 100644
index 0000000..b1ff709
--- /dev/null
+++ b/app/src/main/java/com/example/homecaicaitong/FlagManage.java
@@ -0,0 +1,54 @@
+package com.example.homecaicaitong;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.Toast;
+
+import com.example.homecaicaitong.dao.FlagDAO;
+import com.example.homecaicaitong.model.Tb_flag;
+
+public class FlagManage extends AppCompatActivity {
+ private EditText txtFlag;// 创建EditText对象
+ private Button btnEdit, btnDel;// 创建两个Button对象
+ private String strid;// 创建字符串,表示便签的id
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.flagmanage);// 设置布局文件
+ txtFlag = (EditText) findViewById(R.id.txtFlagManage);// 获取便签文本框
+ btnEdit = (Button) findViewById(R.id.btnFlagManageEdit);// 获取修改按钮
+ btnDel = (Button) findViewById(R.id.btnFlagManageDelete);// 获取删除按钮
+
+ Intent intent = getIntent();// 创建Intent对象
+ Bundle bundle = intent.getExtras();// 获取便签id
+ strid = bundle.getString(Showinfo.FLAG);// 将便签id转换为字符串
+ final FlagDAO flagDAO = new FlagDAO(FlagManage.this);// 创建FlagDAO对象
+ txtFlag.setText(flagDAO.find(Integer.parseInt(strid)).getFlag());// 根据便签id查找便签信息,并显示在文本框中
+
+ btnEdit.setOnClickListener(new View.OnClickListener() {// 为修改按钮设置监听事件
+ @Override
+ public void onClick(View arg0) {
+ Tb_flag tb_flag = new Tb_flag();// 创建Tb_flag对象
+ tb_flag.setid(Integer.parseInt(strid));// 设置便签id
+ tb_flag.setFlag(txtFlag.getText().toString());// 设置便签值
+ flagDAO.update(tb_flag);// 修改便签信息
+ // 弹出信息提示
+ Toast.makeText(FlagManage.this, "〖便签数据〗修改成功!", Toast.LENGTH_SHORT).show();
+ }
+ });
+
+ btnDel.setOnClickListener(new View.OnClickListener() {// 为删除按钮设置监听事件
+ @Override
+ public void onClick(View arg0) {
+ flagDAO.detele(Integer.parseInt(strid));// 根据指定的id删除便签信息
+ Toast.makeText(FlagManage.this, "〖便签数据〗删除成功!", Toast.LENGTH_SHORT).show();
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/homecaicaitong/Inaccountinfo.java b/app/src/main/java/com/example/homecaicaitong/Inaccountinfo.java
new file mode 100644
index 0000000..662d0e5
--- /dev/null
+++ b/app/src/main/java/com/example/homecaicaitong/Inaccountinfo.java
@@ -0,0 +1,71 @@
+package com.example.homecaicaitong;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import com.example.homecaicaitong.dao.InaccountDAO;
+import com.example.homecaicaitong.model.Tb_inaccount;
+
+import java.util.List;
+
+public class Inaccountinfo extends AppCompatActivity {
+ private static final String FLAG = "id";// 定义一个常量,用来作为请求码
+ private ListView lvinfo;// 创建ListView对象
+ private String strType = "";// 创建字符串,记录管理类型
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.inaccountinfo);// 设置布局文件
+ lvinfo = (ListView) findViewById(R.id.lvinaccountinfo);// 获取布局文件中的ListView组件
+
+ showInfo(R.id.btnininfo);// 调用自定义方法显示收入信息
+
+ lvinfo.setOnItemClickListener(new AdapterView.OnItemClickListener() {// 为ListView添加项单击事件
+
+ // 覆写onItemClick方法
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position, long id) {
+ String strInfo = String.valueOf(((TextView) view).getText());// 记录收入信息
+ String strid = strInfo.substring(0, strInfo.indexOf('|'));// 从收入信息中截取收入编号
+ Intent intent = new Intent(Inaccountinfo.this, InfoManage.class);// 创建Intent对象
+ intent.putExtra(FLAG, new String[] { strid, strType });// 设置传递数据
+ startActivity(intent);// 执行Intent操作
+ }
+ });
+ }
+
+ private void showInfo(int intType) {// 用来根据传入的管理类型,显示相应的信息
+ String[] strInfos = null;// 定义字符串数组,用来存储收入信息
+ ArrayAdapter arrayAdapter = null;// 创建ArrayAdapter对象
+ strType = "btnininfo";// 为strType变量赋值
+ InaccountDAO inaccountinfo = new InaccountDAO(Inaccountinfo.this);// 创建InaccountDAO对象
+ // 获取所有收入信息,并存储到List泛型集合中
+ List listinfos = inaccountinfo.getScrollData(0, (int) inaccountinfo.getCount());
+ strInfos = new String[listinfos.size()];// 设置字符串数组的长度
+ int m = 0;// 定义一个开始标识
+ for (Tb_inaccount tb_inaccount : listinfos) {// 遍历List泛型集合
+ // 将收入相关信息组合成一个字符串,存储到字符串数组的相应位置
+ strInfos[m] = tb_inaccount.getid() + "|" + tb_inaccount.getType() + " " + String.valueOf(tb_inaccount.getMoney()) + "元 "
+ + tb_inaccount.getTime();
+ m++;// 标识加1
+ }
+ // 使用字符串数组初始化ArrayAdapter对象
+ arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, strInfos);
+ lvinfo.setAdapter(arrayAdapter);// 为ListView列表设置数据源
+ }
+
+ @Override
+ protected void onRestart() {
+ // TODO Auto-generated method stub
+ super.onRestart();// 实现基类中的方法
+ showInfo(R.id.btnininfo);// 显示收入信息
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/homecaicaitong/InfoManage.java b/app/src/main/java/com/example/homecaicaitong/InfoManage.java
new file mode 100644
index 0000000..9bc8a32
--- /dev/null
+++ b/app/src/main/java/com/example/homecaicaitong/InfoManage.java
@@ -0,0 +1,163 @@
+package com.example.homecaicaitong;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.app.DatePickerDialog;
+import android.app.Dialog;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.DatePicker;
+import android.widget.EditText;
+import android.widget.Spinner;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.example.homecaicaitong.dao.InaccountDAO;
+import com.example.homecaicaitong.dao.OutaccountDAO;
+import com.example.homecaicaitong.model.Tb_inaccount;
+import com.example.homecaicaitong.model.Tb_outaccount;
+
+import java.util.Calendar;
+
+public class InfoManage extends AppCompatActivity {
+ private static final int DATE_DIALOG_ID = 0;// 创建日期对话框常量
+ private TextView tvtitle, textView;// 创建两个TextView对象
+ private EditText txtMoney, txtTime, txtHA, txtMark;// 创建4个EditText对象
+ private Spinner spType;// 创建Spinner对象
+ private Button btnEdit, btnDel;// 创建两个Button对象
+ private String[] strInfos;// 定义字符串数组
+ private String strid, strType;// 定义两个字符串变量,分别用来记录信息编号和管理类型
+
+ private int mYear;// 年
+ private int mMonth;// 月
+ private int mDay;// 日
+
+ private OutaccountDAO outaccountDAO = new OutaccountDAO(InfoManage.this);// 创建OutaccountDAO对象
+ private InaccountDAO inaccountDAO = new InaccountDAO(InfoManage.this);// 创建InaccountDAO对象
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.infomanage);// 设置布局文件
+ tvtitle = (TextView) findViewById(R.id.inouttitle);// 获取标题标签对象
+ textView = (TextView) findViewById(R.id.tvInOut);// 获取地点/付款方标签对象
+ txtMoney = (EditText) findViewById(R.id.txtInOutMoney);// 获取金额文本框
+ txtTime = (EditText) findViewById(R.id.txtInOutTime);// 获取时间文本框
+ spType = (Spinner) findViewById(R.id.spInOutType);// 获取类别下拉列表
+ txtHA = (EditText) findViewById(R.id.txtInOut);// 获取地点/付款方文本框
+ txtMark = (EditText) findViewById(R.id.txtInOutMark);// 获取备注文本框
+ btnEdit = (Button) findViewById(R.id.btnInOutEdit);// 获取修改按钮
+ btnDel = (Button) findViewById(R.id.btnInOutDelete);// 获取删除按钮
+
+ Intent intent = getIntent();// 创建Intent对象
+ Bundle bundle = intent.getExtras();// 获取传入的数据,并使用Bundle记录
+ strInfos = bundle.getStringArray(Showinfo.FLAG);// 获取Bundle中记录的信息
+ strid = strInfos[0];// 记录id
+ strType = strInfos[1];// 记录类型
+ if (strType.equals("btnoutinfo")) {// 如果类型是btnoutinfo
+
+ tvtitle.setText("支出管理");// 设置标题为“支出管理”
+ textView.setText("地 点:");// 设置“地点/付款方”标签文本为“地 点:”
+ // 根据编号查找支出信息,并存储到Tb_outaccount对象中
+ Tb_outaccount tb_outaccount = outaccountDAO.find(Integer.parseInt(strid));
+ txtMoney.setText(String.valueOf(tb_outaccount.getMoney()));// 显示金额
+ txtTime.setText(tb_outaccount.getTime());// 显示时间
+ spType.setPrompt(tb_outaccount.getType());// 显示类别
+ txtHA.setText(tb_outaccount.getAddress());// 显示地点
+ txtMark.setText(tb_outaccount.getMark());// 显示备注
+ } else if (strType.equals("btnininfo")) {// 如果类型是btnininfo
+
+ tvtitle.setText("收入管理");// 设置标题为“收入管理”
+ textView.setText("付款方:");// 设置“地点/付款方”标签文本为“付款方:”
+ // 根据编号查找收入信息,并存储到Tb_outaccount对象中
+ Tb_inaccount tb_inaccount = inaccountDAO.find(Integer.parseInt(strid));
+ txtMoney.setText(String.valueOf(tb_inaccount.getMoney()));// 显示金额
+ txtTime.setText(tb_inaccount.getTime());// 显示时间
+ spType.setPrompt(tb_inaccount.getType());// 显示类别
+ txtHA.setText(tb_inaccount.getHandler());// 显示付款方
+ txtMark.setText(tb_inaccount.getMark());// 显示备注
+ }
+
+ txtTime.setOnClickListener(new View.OnClickListener() {// 为时间文本框设置单击监听事件
+ @Override
+ public void onClick(View arg0) {
+ showDialog(DATE_DIALOG_ID);// 显示日期选择对话框
+ }
+ });
+
+ btnEdit.setOnClickListener(new View.OnClickListener() {// 为修改按钮设置监听事件
+ @Override
+ public void onClick(View arg0) {
+ if (strType.equals("btnoutinfo")) {// 判断类型如果是btnoutinfo
+
+ Tb_outaccount tb_outaccount = new Tb_outaccount();// 创建Tb_outaccount对象
+ tb_outaccount.setid(Integer.parseInt(strid));// 设置编号
+ tb_outaccount.setMoney(Double.parseDouble(txtMoney.getText().toString()));// 设置金额
+ tb_outaccount.setTime(txtTime.getText().toString());// 设置时间
+ tb_outaccount.setType(spType.getSelectedItem().toString());// 设置类别
+ tb_outaccount.setAddress(txtHA.getText().toString());// 设置地点
+ tb_outaccount.setMark(txtMark.getText().toString());// 设置备注
+ outaccountDAO.update(tb_outaccount);// 更新支出信息
+ } else if (strType.equals("btnininfo")) {// 判断类型如果是btnininfo
+
+ Tb_inaccount tb_inaccount = new Tb_inaccount();// 创建Tb_inaccount对象
+ tb_inaccount.setid(Integer.parseInt(strid));// 设置编号
+ tb_inaccount.setMoney(Double.parseDouble(txtMoney.getText().toString()));// 设置金额
+ tb_inaccount.setTime(txtTime.getText().toString());// 设置时间
+ tb_inaccount.setType(spType.getSelectedItem().toString());// 设置类别
+ tb_inaccount.setHandler(txtHA.getText().toString());// 设置付款方
+ tb_inaccount.setMark(txtMark.getText().toString());// 设置备注
+ inaccountDAO.update(tb_inaccount);// 更新收入信息
+ }
+ // 弹出信息提示
+ Toast.makeText(InfoManage.this, "〖数据〗修改成功!", Toast.LENGTH_SHORT).show();
+ }
+ });
+
+ btnDel.setOnClickListener(new View.OnClickListener() {// 为删除按钮设置监听事件
+ @Override
+ public void onClick(View arg0) {
+ if (strType.equals("btnoutinfo")) {// 判断类型如果是btnoutinfo
+
+ outaccountDAO.detele(Integer.parseInt(strid));// 根据编号删除支出信息
+ } else if (strType.equals("btnininfo")) {// 判断类型如果是btnininfo
+
+ inaccountDAO.detele(Integer.parseInt(strid));// 根据编号删除收入信息
+ }
+ Toast.makeText(InfoManage.this, "〖数据〗删除成功!", Toast.LENGTH_SHORT).show();
+ }
+ });
+
+ final Calendar c = Calendar.getInstance();// 获取当前系统日期
+ mYear = c.get(Calendar.YEAR);// 获取年份
+ mMonth = c.get(Calendar.MONTH);// 获取月份
+ mDay = c.get(Calendar.DAY_OF_MONTH);// 获取天数
+ updateDisplay();// 显示当前系统时间
+ }
+
+ @Override
+ protected Dialog onCreateDialog(int id) {// 重写onCreateDialog方法
+
+ switch (id) {
+ case DATE_DIALOG_ID:// 弹出日期选择对话框
+ return new DatePickerDialog(this, mDateSetListener, mYear, mMonth, mDay);
+ }
+ return null;
+ }
+
+ private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() {
+ public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
+ mYear = year;// 为年份赋值
+ mMonth = monthOfYear;// 为月份赋值
+ mDay = dayOfMonth;// 为天赋值
+ updateDisplay();// 显示设置的日期
+ }
+ };
+
+ private void updateDisplay() {
+ // 显示设置的时间
+ txtTime.setText(new StringBuilder().append(mYear).append("-").append(mMonth + 1).append("-").append(mDay));
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/homecaicaitong/Login.java b/app/src/main/java/com/example/homecaicaitong/Login.java
new file mode 100644
index 0000000..1760ada
--- /dev/null
+++ b/app/src/main/java/com/example/homecaicaitong/Login.java
@@ -0,0 +1,54 @@
+package com.example.homecaicaitong;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.Toast;
+
+import com.example.homecaicaitong.dao.PwdDAO;
+
+public class Login extends AppCompatActivity {
+ private EditText txtlogin;// 创建EditText对象
+ private Button btnlogin, btnclose;// 创建两个Button对象
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.login);// 设置布局文件
+
+ txtlogin = (EditText) findViewById(R.id.txtLogin);// 获取密码文本框
+ btnlogin = (Button) findViewById(R.id.btnLogin);// 获取登录按钮
+ btnclose = (Button) findViewById(R.id.btnClose);// 获取取消按钮
+
+ btnlogin.setOnClickListener(new View.OnClickListener() {// 为登录按钮设置监听事件
+ @Override
+ public void onClick(View arg0) {
+ Intent intent = new Intent(Login.this, MainActivity.class);// 创建Intent对象
+ PwdDAO pwdDAO = new PwdDAO(Login.this);// 创建PwdDAO对象
+ // 判断是否有密码及是否输入了密码
+ if ((pwdDAO.getCount() == 0 || pwdDAO.find().getPassword().isEmpty()) && txtlogin.getText().toString().isEmpty()) {
+ startActivity(intent);// 启动主Activity
+ } else {
+ // 判断输入的密码是否与数据库中的密码一致
+ if (pwdDAO.find().getPassword().equals(txtlogin.getText().toString())) {
+ startActivity(intent);// 启动主Activity
+ } else {
+ // 弹出信息提示
+ Toast.makeText(Login.this, "请输入正确的密码!", Toast.LENGTH_SHORT).show();
+ }
+ }
+ txtlogin.setText("");// 清空密码文本框
+ }
+ });
+
+ btnclose.setOnClickListener(new View.OnClickListener() {// 为取消按钮设置监听事件
+ @Override
+ public void onClick(View arg0) {
+ finish();// 退出当前程序
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/homecaicaitong/MainActivity.java b/app/src/main/java/com/example/homecaicaitong/MainActivity.java
new file mode 100644
index 0000000..9f0b8ee
--- /dev/null
+++ b/app/src/main/java/com/example/homecaicaitong/MainActivity.java
@@ -0,0 +1,169 @@
+package com.example.homecaicaitong;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.BaseAdapter;
+import android.widget.GridView;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MainActivity extends AppCompatActivity {
+ private GridView gvInfo;// 创建GridView对象
+ // 定义字符串数组,存储系统功能
+ private String[] titles = new String[] { "新增支出", "新增收入", "我的支出", "我的收入", "数据管理", "系统设置", "收支便签", "退出" };
+ // 定义int数组,存储功能对应的图标
+ private int[] images = new int[] { R.drawable.addoutaccount, R.drawable.addinaccount, R.drawable.outaccountinfo, R.drawable.inaccountinfo,
+ R.drawable.showinfo, R.drawable.sysset, R.drawable.accountflag, R.drawable.exit };
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ gvInfo = (GridView) findViewById(R.id.gvInfo);// 获取布局文件中的gvInfo组件
+ PictureAdapter adapter = new PictureAdapter(titles, images, this);// 创建pictureAdapter对象
+ gvInfo.setAdapter(adapter);// 为GridView设置数据源
+ gvInfo.setOnItemClickListener(new AdapterView.OnItemClickListener() {// 为GridView设置项单击事件
+ @Override
+ public void onItemClick(AdapterView> arg0, View arg1, int arg2, long arg3) {
+ Intent intent = null;// 创建Intent对象
+ switch (arg2) {
+ case 0:
+ intent = new Intent(MainActivity.this, AddOutaccount.class);// 使用AddOutaccount窗口初始化Intent
+ startActivity(intent);// 打开AddOutaccount
+ break;
+ case 1:
+ intent = new Intent(MainActivity.this, AddInaccount.class);// 使用AddInaccount窗口初始化Intent
+ startActivity(intent);// 打开AddInaccount
+ break;
+ case 2:
+ intent = new Intent(MainActivity.this, Outaccountinfo.class);// 使用Outaccountinfo窗口初始化Intent
+ startActivity(intent);// 打开Outaccountinfo
+ break;
+ case 3:
+ intent = new Intent(MainActivity.this, Inaccountinfo.class);// 使用Inaccountinfo窗口初始化Intent
+ startActivity(intent);// 打开Inaccountinfo
+ break;
+ case 4:
+ intent = new Intent(MainActivity.this, Showinfo.class);// 使用Showinfo窗口初始化Intent
+ startActivity(intent);// 打开Showinfo
+ break;
+ case 5:
+ intent = new Intent(MainActivity.this, Sysset.class);// 使用Sysset窗口初始化Intent
+ startActivity(intent);// 打开Sysset
+ break;
+ case 6:
+ intent = new Intent(MainActivity.this, Accountflag.class);// 使用Accountflag窗口初始化Intent
+ startActivity(intent);// 打开Accountflag
+ break;
+ case 7:
+ finish();// 关闭当前Activity
+ }
+ }
+ });
+ }
+}
+class PictureAdapter extends BaseAdapter {// 创建基于BaseAdapter的子类
+
+ private LayoutInflater inflater;// 创建LayoutInflater对象
+ private List