提交 5d6b3994 编写于 作者: Z zhao

a

上级 2dd156ad
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/teamwork.iml" filepath="$PROJECT_DIR$/.idea/teamwork.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" />
<bytecodeTargetLevel target="17" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
......
......@@ -12,6 +12,12 @@
android:supportsRtl="true"
android:theme="@style/Theme.1"
tools:targetApi="31" >
<activity
android:name=".SearchActivity"
android:exported="false" />
<activity
android:name=".AboutActivity"
android:exported="false" />
<activity
android:name=".RecordActivity"
android:exported="false" />
......
package com.example.jizhangben;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class AboutActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
}
}
\ No newline at end of file
......@@ -29,6 +29,7 @@ import java.util.Set;
import utils.BudgetDialog;
import utils.MoreDialog;
public class MainActivity<MoreDialog> extends AppCompatActivity implements View.OnClickListener {
ListView todayLv;
......@@ -65,9 +66,46 @@ public class MainActivity<MoreDialog> extends AppCompatActivity implements View.
editBtn.setOnClickListener(this);
moreBtn.setOnClickListener(this);
searchIv.setOnClickListener(this);
setLVLongClickListener();
}
/**设置ListView的长按事件**/
private void setLVLongClickListener(){
todayLv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
if(position==0){ //点击了头布局
return false;
}
int pos = position - 1;
AccountBean clickBean = mDatas.get(pos); //获取正在被点击的这条信息
// 弹出提示用户是否删除的对话框
showDeleteItemDialog(clickBean);
return false;
}
});
}
/*弹出是否删除某一条记录的对话框*/
private void showDeleteItemDialog(final AccountBean clickBean){
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setTitle("提示信息").setMessage("您确定要删除这条记录吗?")
.setNegativeButton("取消",null)
.setPositiveButton("确定",new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog,int which){
int click_id=clickBean.getId();
//执行删除操作
DBManager.deleteItemFromAccounttbById(click_id);
mDatas.remove(clickBean); //实时刷新,移除集合中的对象
adapter.notifyDataSetChanged(); //提示适配器更新数据
setTopTvShow(); //改变头布局TextView显示的内容
}
});
}
private void addLVHeaderView() {
......@@ -137,7 +175,7 @@ public class MainActivity<MoreDialog> extends AppCompatActivity implements View.
public void onClick(View v) {
switch (v.getId()) {
case R.id.main_iv_search:
Intent it = new Intent(this,RecordActivity.class) ; //跳转界面
Intent it = new Intent(this,SearchActivity.class) ; //跳转界面
startActivity(it);
break;
case R.id.main_btn_edit:
......@@ -145,7 +183,6 @@ public class MainActivity<MoreDialog> extends AppCompatActivity implements View.
startActivity(it1);
break;
case R.id.main_btn_more:
break;
case R.id.item_mainlv_top_tv_budget:
showBudgetDialog();
......
package com.example.jizhangben;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.example.jizhangben.adapter.AccountAdapter;
import com.example.jizhangben.db.AccountBean;
import com.example.jizhangben.db.DBManager;
import java.util.ArrayList;
import java.util.List;
public class SearchActivity extends AppCompatActivity {
ListView searchLv;
EditText searchEt;
TextView emptyTv;
List<AccountBean> mDatas; //数据源
AccountAdapter adapter; //适配器对象
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search);
initView();
mDatas=new ArrayList<>();
adapter=new AccountAdapter(this,mDatas);
searchLv.setAdapter(adapter);
searchLv.setEmptyView(emptyTv); //设置无数据时,显示的控件
}
private void initView(){
searchEt=findViewById(R.id.search_et);
searchLv=findViewById(R.id.search_lv);
emptyTv=findViewById(R.id.search_tv_empty);
}
public void onClick(View view){
switch (view.getId()){
case R.id.search_iv_back:
finish();
break;
case R.id.search_iv_sh: //执行搜索的操作
String msg = searchEt.getText().toString().trim();
//判断输入内容是否为空,如果为空,就提示不能检索
if(TextUtils.isEmpty(msg)){
Toast.makeText(this, "输入内容不能为空!", Toast.LENGTH_SHORT).show();
}
//开始搜索
List<AccountBean> list = DBManager.getAccountListByRemarkFromAccounttb(msg);
mDatas.clear();
mDatas.addAll(list);
adapter.notifyDataSetChanged();
break;
}
}
}
\ No newline at end of file
......@@ -101,6 +101,36 @@ public class DBManager {
}
return total;
}
/*
*根据传入的id,删除accounttb表当中的一条数据
**/
public static int deleteItemFromAccounttbById(int id){
int i=db.delete("accounttb","id=?",new String[]{id+""});
return i;
}
/*
* 根据备注搜索收入或者支出的情况列表
**/
public static List<AccountBean>getAccountListByRemarkFromAccounttb(String beizhu){
List<AccountBean>list = new ArrayList<>();
String sql="select * from accounttb where beizhu like '%"+beizhu+"%'";
Cursor cursor =db.rawQuery(sql,null);
while (cursor.moveToNext()){
int id = cursor.getInt(cursor.getColumnIndexOrThrow("id"));
String typename = cursor.getString(cursor.getColumnIndexOrThrow("typename"));
String bz = cursor.getString(cursor.getColumnIndexOrThrow("beizhu"));
String time = cursor.getString(cursor.getColumnIndexOrThrow("time"));
int sImageId = cursor.getInt(cursor.getColumnIndexOrThrow("sImageId"));
int kind = cursor.getInt(cursor.getColumnIndexOrThrow("kind"));
float money = cursor.getFloat(cursor.getColumnIndexOrThrow("money"));
int year=cursor.getInt(cursor.getColumnIndexOrThrow("year"));
int month=cursor.getInt(cursor.getColumnIndexOrThrow("month"));
int day=cursor.getInt(cursor.getColumnIndexOrThrow("day"));
AccountBean accountBean = new AccountBean(id, typename, sImageId, bz, money, time, year, month, day, kind);
list.add(accountBean);
}
return list;
}
}
package utils;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Display;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import com.example.jizhangben.AboutActivity;
import com.example.jizhangben.R;
public class MoreDialog extends Dialog implements View.OnClickListener {
Button aboutBtn,settingBtn,historyBtn,infoBtn;
ImageView errorIv;
public MoreDialog(@NonNull Context context) {
super(context);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog_more);
aboutBtn=findViewById(R.id.dialog_more_btn_about);
settingBtn=findViewById(R.id.dialog_more_btn_setting);
historyBtn=findViewById(R.id.dialog_more_btn_record);
infoBtn=findViewById(R.id.dialog_more_btn_info);
errorIv=findViewById(R.id.dialog_more_iv);
aboutBtn.setOnClickListener(this);
settingBtn.setOnClickListener(this);
historyBtn.setOnClickListener(this);
infoBtn.setOnClickListener(this);
errorIv.setOnClickListener(this);
}
@Override
public void onClick(View v) {
Intent intent=new Intent();
switch (v.getId()){
case R.id.dialog_more_btn_about:
intent.setClass(getContext(), AboutActivity.class);
getContext().startActivity(intent);
break;
case R.id.dialog_more_btn_setting:
break;
case R.id.dialog_more_btn_record:
break;
case R.id.dialog_more_btn_info:
break;
case R.id.dialog_more_iv:
break;
}
cancel();
}
public void setDialogSize(){
// 获取当前窗口对象
Window window = getWindow();
// 获取窗口对象的参数
WindowManager.LayoutParams wlp = window.getAttributes();
// 获取屏幕宽度
Display d = window.getWindowManager().getDefaultDisplay();
wlp.width = (int)(d.getWidth()); //对话框窗口为屏幕窗口
wlp.gravity = Gravity.BOTTOM;
window.setBackgroundDrawableResource(android.R.color.transparent);
window.setAttributes(wlp);
}
}
<?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"
android:background="@color/grey_f3f3f3">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@mipmap/it_back"
android:onClick="onClick"
android:minHeight="48dp"
android:minWidth="48dp"
android:layout_marginLeft="10dp"
android:contentDescription="TODO" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/about"
android:textSize="18sp"
android:textStyle="bold"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about_appinfo"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about_version"
android:layout_marginTop="10dp"
android:textStyle="bold"
android:textSize="16sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/about_1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textStyle="bold"
android:textSize="16sp"
android:text="@string/about_app"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/about_re"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/about_developer"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textStyle="bold"
android:textSize="16sp"
android:text="@string/about_me"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/about_loc"/>
</LinearLayout>
</LinearLayout>
<?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"
android:background="@color/grey_f3f3f3">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp">
<ImageView
android:id="@+id/search_iv_back"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:onClick="onClick"
android:layout_marginLeft="10dp"
android:src="@mipmap/it_back"
tools:ignore="UsingOnClickInXml" />
<EditText
android:id="@+id/search_et"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/search_iv_back"
android:background="@drawable/dialog_btn_bg"
android:layout_centerVertical="true"
android:textSixe="16sp"
android:padding="10dp"
android:paddingBottom="10dp"
android:paddingLeft="20dp"
android:layout_marginLeft="10dp"
android:hint="@string/please_search_info">
<requestFocus/>
</EditText>
<ImageView
android:id="@+id/search_iv_sh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/search"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="20dp"
android:onClick="onClick"/>
</RelativeLayout>
<ListView
android:id="@+id/search_lv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:dividerHeight="6dp"
android:divider="@color/grey_f3f3f3"
android:visibility="gone"
/>
<TextView
android:id="@+id/search_tv_empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/date_empty"
android:gravity="center"
android:textSize="22sp"
android:drawableTop="@mipmap/it_searchtext"
android:layout_marginTop="250dp"/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="20dp"
android:background="@color/grey_f3f3f3">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/dialog_more_btn_about"
style="@style/dialogmoreStyle"
android:drawableTop="@mipmap/it_guanyu"
android:text="@string/about"/>
<Button
android:id="@+id/dialog_more_btn_setting"
style="@style/dialogmoreStyle"
android:drawableTop="@mipmap/it_shezhi"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:text="@string/setting"/>
<Button
android:id="@+id/dialog_more_btn_record"
style="@style/dialogmoreStyle"
android:drawableTop="@mipmap/it_jilu"
android:text="@string/history_record"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_marginTop="20dp"
android:weightSum="3">
<Button
android:id="@+id/dialog_more_btn_info"
style="@style/dialogmoreStyle"
android:drawableTop="@mipmap/it_xiqing"
android:text="@string/account_info"
android:layout_marginRight="30dp"/>
</LinearLayout>
<ImageView
android:id="@+id/dialog_more_iv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/in_error"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"/>
</androidx.appcompat.widget.LinearLayoutCompat>
\ No newline at end of file
......@@ -9,8 +9,22 @@
<string name="remark">备注</string>
<string name="ensure">确定</string>
<string name="cancel">取消</string>
<string name="about">关于</string>
<string name="setting">设置</string>
<string name="history_record">账单记录</string>
<string name="account_info">账单详情</string>
<string name="please_input_time">请输入时间(24小时制)</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="please_search_info">请输入搜索信息</string>
<string name="date_empty">数据为空无此类记录</string>
<string name="about_appinfo">应用信息</string>
<string name="about_version">版本</string>
<string name="about_1">1.0</string>
<string name="about_app">关于应用</string>
<string name="about_re">记录个人或单位日常的收支的明细,资产增减等经济业务发生情况,有利于理财,并为经济管理及投资决策提供依据等。</string>
<string name="about_developer">开发者</string>
<string name="about_me">关于我</string>
<string name="about_loc">位于广东广州的大学生团队</string>
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources>
\ No newline at end of file
......@@ -16,4 +16,6 @@
<item name="android:layout_height">100dp</item>
<item name="android:layout_width">0dp</item>
</style>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/AS" isTestSource="false" packagePrefix="src.AS.app.src.main.java.com.example.jizhangben.adapter" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册