Skip to content

Commit

Permalink
初始化Demo
Browse files Browse the repository at this point in the history
  • Loading branch information
zthuii committed Oct 21, 2021
1 parent 08d7cec commit 8fdc5a3
Show file tree
Hide file tree
Showing 79 changed files with 3,239 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# HomeCaicaitong
安卓小项目-家庭收支便签
11
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
44 changes: 44 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@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());
}
}
53 changes: 53 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.homecaicaitong">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="Demo"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.HomeCaicaitong">
<activity
android:name=".Sysset"
android:exported="false" />
<activity
android:name=".Showinfo"
android:exported="false" />
<activity
android:name=".Outaccountinfo"
android:exported="false" />
<activity
android:name=".InfoManage"
android:exported="false" />
<activity
android:name=".Inaccountinfo"
android:exported="false" />
<activity
android:name=".FlagManage"
android:exported="false" />
<activity
android:name=".AddOutaccount"
android:exported="false" />
<activity
android:name=".AddInaccount"
android:exported="false" />
<activity
android:name=".Accountflag"
android:exported="false" />
<activity
android:name=".Login"
android:exported="false" />
<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>
</application>

</manifest>
50 changes: 50 additions & 0 deletions app/src/main/java/com/example/homecaicaitong/Accountflag.java
Original file line number Diff line number Diff line change
@@ -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("");// ??????????
}
});
}
}
113 changes: 113 additions & 0 deletions app/src/main/java/com/example/homecaicaitong/AddInaccount.java
Original file line number Diff line number Diff line change
@@ -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));
}
}
Loading

0 comments on commit 8fdc5a3

Please sign in to comment.