一、需求分析

在我们生活中经常不知道钱花在什么地方,但是我们自己又不是很想写在记账本上进行管理,由于智能手机的兴起,手机离我们越来越近,导致我们生活时时刻刻都有手机的存在,所以说手机的操作离我们越来越近,趋势越来越明显。但是对于记账,我们往往每个人都有自己的需求,所以对于自己来说,开发一个简单的软件来记账是个非常好玩且有趣的事情。
所以自己趁着学习Android开发的机会,顺便做一个练习项目,本人小白,一开始啥都不懂,但是我有一颗不断学习的心,相信只要自己努力,怎能够作出自己的事业。
我就简单的分析自己需求,对于衣食住行进行分类,然后记录每天的时间,记录下消费的原因,最为重要的就是金额了。总会做个账单统计,分析自己当前的支出和收入,离预算还有多少钱花费。

二、设计界面

账户界面:

记账界面:

功能区界面:

账单显示界面:

补充:功能区实现的功能目前有:记一笔,账单,导出数据,同步数据,其他功能待实现,其实我本人还想做个计一划的实现,实现记账和日常安排计划同时实现。

三、程序设计

由于高仿微信的界面的实现,所有用了Fragment的布局,滑动切换界面,点击功能区按钮来实现对应功能的添加。
这里面用到的技术主要有ListView,Fragment+viewpage,Activity,sqlite数据库技术,还有Post传参来实现同步服务器端的数据。由于服务端框架接触的少,所以功能只有同步数据。同步数据用到了service实现和操作excel技术。

四、代码实现

首先介绍主界面的实现:Fragment+activity布局
MainActivity.java

package com.bank;import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;import java.util.ArrayList;
import java.util.List;public class MainActivity extends FragmentActivity implements View.OnClickListener {private View.OnClickListener onclicklistene;private ViewPager mViewPager;private FragmentPagerAdapter mAdapter;private List<Fragment> mFragments = new ArrayList<Fragment>();/*** 底部四个按钮*/private LinearLayout mTabBtnWeixin;private LinearLayout mTabBtnFrd;private LinearLayout mTabBtnAddress;private LinearLayout mTabBtnSettings;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);mViewPager = (ViewPager) findViewById(R.id.id_viewpager);initView();findViewById(R.id.btn_tab_bottom_weixin).setOnClickListener(this);findViewById(R.id.btn_tab_bottom_contact).setOnClickListener(this);findViewById(R.id.btn_tab_bottom_friend).setOnClickListener(this);findViewById(R.id.btn_tab_bottom_setting).setOnClickListener(this);mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {@Overridepublic int getCount() {return mFragments.size();}@Overridepublic Fragment getItem(int arg0) {return mFragments.get(arg0);}};mViewPager.setAdapter(mAdapter);mViewPager.addOnPageChangeListener(new OnPageChangeListener() {private int currentIndex;@Overridepublic void onPageSelected(int position) {resetTabBtn();switch (position) {case 0:((ImageButton) mTabBtnWeixin.findViewById(R.id.btn_tab_bottom_weixin)).setImageResource(R.drawable.tab_weixin_pressed);break;case 1:((ImageButton) mTabBtnFrd.findViewById(R.id.btn_tab_bottom_friend)).setImageResource(R.drawable.tab_find_frd_pressed);break;case 2:((ImageButton) mTabBtnAddress.findViewById(R.id.btn_tab_bottom_contact)).setImageResource(R.drawable.tab_address_pressed);break;case 3:((ImageButton) mTabBtnSettings.findViewById(R.id.btn_tab_bottom_setting)).setImageResource(R.drawable.tab_settings_pressed);break;}currentIndex = position;}@Overridepublic void onPageScrolled(int arg0, float arg1, int arg2) {}@Overridepublic void onPageScrollStateChanged(int arg0) {}});}protected void resetTabBtn() {((ImageButton) mTabBtnWeixin.findViewById(R.id.btn_tab_bottom_weixin)).setImageResource(R.drawable.tab_weixin_normal);((ImageButton) mTabBtnFrd.findViewById(R.id.btn_tab_bottom_friend)).setImageResource(R.drawable.tab_find_frd_normal);((ImageButton) mTabBtnAddress.findViewById(R.id.btn_tab_bottom_contact)).setImageResource(R.drawable.tab_address_normal);((ImageButton) mTabBtnSettings.findViewById(R.id.btn_tab_bottom_setting)).setImageResource(R.drawable.tab_settings_normal);}private void initView() {mTabBtnWeixin = (LinearLayout) findViewById(R.id.id_tab_bottom_weixin);mTabBtnFrd = (LinearLayout) findViewById(R.id.id_tab_bottom_friend);mTabBtnAddress = (LinearLayout) findViewById(R.id.id_tab_bottom_contact);mTabBtnSettings = (LinearLayout) findViewById(R.id.id_tab_bottom_setting);FragmentAccount fragmentaccount = new FragmentAccount();FragmentFind fragmentfind = new FragmentFind();FragmentPlan fragmentplan = new FragmentPlan();//        MainTab02 tab02 = new MainTab02();//      FragmentBills fragmentbills = new FragmentBills();MainTab04 tab04 = new MainTab04();mFragments.add(fragmentaccount);mFragments.add(fragmentplan);mFragments.add(fragmentfind);mFragments.add(tab04);}public void onClick(View v) {switch (v.getId()) {case R.id.btn_tab_bottom_weixin:mViewPager.setCurrentItem(0, true);break;case R.id.btn_tab_bottom_friend:mViewPager.setCurrentItem(1, true);break;case R.id.btn_tab_bottom_contact:mViewPager.setCurrentItem(2, true);break;case R.id.btn_tab_bottom_setting:mViewPager.setCurrentItem(3, true);break;}}
}

接下来就是Fragment的实现,我一开始测试中用了4个Fragment来实现,由于有些还需要添加新的功能,所以第一版还是有些挫和部分功能还没有实现。

FragmentAccount.java

package com.bank;import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;import java.text.DecimalFormat;public class FragmentAccount extends Fragment {private MySQLiteHelper mMysql;private SQLiteDatabase mDataBase;private TextView textRemainder,textPay,textIncome;@Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {View view = inflater.inflate(R.layout.finance_check, container, false);double resultIncome = 0,resultRemainder = 0,resultPay = 0;textIncome      = (TextView)view.findViewById(R.id.textincome);textRemainder      = (TextView)view.findViewById(R.id.textremainder);textPay      = (TextView)view.findViewById(R.id.textpay);mMysql = new MySQLiteHelper(getActivity(), "finance.db", null, 1);mDataBase = mMysql.getReadableDatabase();//   String sql      = "select Fee from finance where Budget='支出'";//Cursor cursor = mDataBase.query("finance", null, null, null, null, null, null);//  Cursor cursor = mDataBase.query("finance", new String[]{"Fee"},"where Budget=?",new String[]{"支出"},null,null,null);
// String sql      ="insert into finance('Type','Time','Fee','Remarks','Budget') values('衣','20160330',37.6,'买衣服','支出')";
//                int i =0;
//                while( i<20)
//                {
//                        mDataBase.execSQL(sql);
//                        i++;
//                }Cursor cursor = mDataBase.rawQuery("select Fee,Budget from finance",null);cursor.moveToFirst();if (cursor.getCount() > 0) {for (int i = 0; i < cursor.getCount(); i++) {//  cursor.move(i);//移动到指定记录double Fee = cursor.getDouble(cursor.getColumnIndex("Fee"));String budget = cursor.getString(cursor.getColumnIndex("Budget"));if(budget.equals("支出")) {resultPay += Fee;} else if (budget.equals("收入")){resultIncome += Fee;}cursor.moveToNext();}}DecimalFormat df = new DecimalFormat("###.##");textPay.setText(String.valueOf(df.format(resultPay)));textIncome.setText(String.valueOf(df.format(resultIncome)));textRemainder.setText(String.valueOf(df.format(resultIncome - resultPay)));cursor.close();mDataBase.close();mMysql.close();return view;}
}

FragmentFind.java

package com.bank;import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Vibrator;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.Toast;import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.ArrayList;import android.database.sqlite.SQLiteDatabase;public class FragmentFind extends Fragment implements View.OnClickListener {private FrameLayout frameLayout_recorder;private FrameLayout frameLayout_bills;private FrameLayout frameLayout_test;private FrameLayout frameLayout_plan;private FrameLayout frameLayout_SubmitData;private FrameLayout frameLayout_ExportData;//数据库private MySQLiteHelper mMysql;private SQLiteDatabase mDataBase;//震动的类private Vibrator vibrator;@Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {View view = inflater.inflate(R.layout.deal_data, container, false);frameLayout_recorder = (FrameLayout) view.findViewById(R.id.frameLayoutRecorder);frameLayout_bills = (FrameLayout) view.findViewById(R.id.frameLayoutStream);frameLayout_test = (FrameLayout) view.findViewById(R.id.frameLayoutBalance);frameLayout_plan = (FrameLayout) view.findViewById(R.id.frameLayoutPlan);frameLayout_SubmitData = (FrameLayout) view.findViewById(R.id.frameLayoutSubmitdata);frameLayout_ExportData = (FrameLayout) view.findViewById(R.id.frameLayoutExportdata);frameLayout_test.setOnClickListener(this);frameLayout_bills.setOnClickListener(this);frameLayout_recorder.setOnClickListener(this);frameLayout_plan.setOnClickListener(this);frameLayout_SubmitData.setOnClickListener(this);frameLayout_ExportData.setOnClickListener(this);return view;}@Overridepublic void onClick(View view) {switch (view.getId()) {case R.id.frameLayoutRecorder:Intent intent = new Intent(getActivity(), RecorderActivity.class);startActivity(intent);break;case R.id.frameLayoutStream:startActivity(new Intent(getActivity(), BillsActivity.class));break;case R.id.frameLayoutBalance:final int SHOW_INFO = 1;Intent testintent = new Intent(getActivity(), TestActivity.class);Bundle bundle = new Bundle();//传递name参数为tinyphpbundle.putString("Type", "其他");bundle.putString("Time", "2016-05-21");bundle.putString("Budget", "收入");bundle.putDouble("Fee", 12.5);bundle.putInt("ID", 12);bundle.putString("Remarks", "现金交易");testintent.putExtras(bundle);startActivityForResult(testintent, SHOW_INFO);break;case R.id.frameLayoutPlan://消息通知栏//定义NotificationManagerString ns = Context.NOTIFICATION_SERVICE;NotificationManager mNotificationManager = (NotificationManager) getActivity().getSystemService(ns);//定义通知栏展现的内容信息int icon = R.drawable.back;CharSequence tickerText = "通知栏";long when = System.currentTimeMillis();Notification notification = new Notification(icon, tickerText, when);//定义下拉通知栏时要展现的内容信息Context context = getActivity().getApplicationContext();CharSequence contentTitle = "已经完成同步";CharSequence contentText = "进入程序查看详情";Intent notificationIntent = new Intent(getActivity(), MainActivity.class);PendingIntent contentIntent = PendingIntent.getActivity(getActivity(), 0,notificationIntent, 0);notification.setLatestEventInfo(context, contentTitle, contentText,contentIntent);//用mNotificationManager的notify方法通知用户生成标题栏消息通知mNotificationManager.notify(1, notification);startActivity(new Intent(getActivity(), PlanActivity.class));break;case R.id.frameLayoutSubmitdata:Toast.makeText(getActivity(), "正在同步", Toast.LENGTH_SHORT).show();Intent dataintent = new Intent();dataintent.setClass(getActivity(), SubmitDataService.class);getActivity().startService(dataintent);break;case R.id.frameLayoutExportdata:Toast.makeText(getActivity(),"正在导出数据",Toast.LENGTH_SHORT).show();ExportData();break;default:break;}}public void ExportData() {String outputFile = "finance.xls";try {// 判断是否存在SD卡if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {} else {Toast.makeText(getActivity(), "sd卡不存在", Toast.LENGTH_LONG).show();return;}String sdCardRoot = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Finance/";File file = new File(sdCardRoot + outputFile);// 创建新的Excel 工作簿HSSFWorkbook workbook = new HSSFWorkbook();// 在Excel工作簿中建一工作表,其名为缺省值// 如要新建一名为"效益指标"的工作表,其语句为:// HSSFSheet sheet = workbook.createSheet("效益指标");HSSFSheet sheet = workbook.createSheet("消费记录");// 在索引0的位置创建行(最顶端的行)HSSFRow row = sheet.createRow((short) 0);//创建表头HSSFCell IDCell = row.createCell(0);IDCell.setCellType(HSSFCell.CELL_TYPE_STRING);IDCell.setCellValue("ID(ID号)");HSSFCell TypeCell = row.createCell(1);TypeCell.setCellType(HSSFCell.CELL_TYPE_STRING);TypeCell.setCellValue("Type(类型)");HSSFCell TimeCell = row.createCell(2);TimeCell.setCellType(HSSFCell.CELL_TYPE_STRING);TimeCell.setCellValue("Time(时间)");HSSFCell FeeCell = row.createCell(3);FeeCell.setCellType(HSSFCell.CELL_TYPE_STRING);FeeCell.setCellValue("Fee(费用)");HSSFCell RemarksCell = row.createCell(4);RemarksCell.setCellType(HSSFCell.CELL_TYPE_STRING);RemarksCell.setCellValue("Remarks(备注)");HSSFCell BudgetCell = row.createCell(5);BudgetCell.setCellType(HSSFCell.CELL_TYPE_STRING);BudgetCell.setCellValue("Budget(收支)");mMysql = new MySQLiteHelper(getActivity(), "finance.db", null, 1);mDataBase = mMysql.getReadableDatabase();Cursor cursor = mDataBase.rawQuery("select * from finance", null);cursor.moveToFirst();int columnsSize = cursor.getColumnCount();int number = 0;while (number < cursor.getCount()) {String budget = cursor.getString(cursor.getColumnIndex("Budget"));int ID = cursor.getInt(cursor.getColumnIndex("ID"));Double Fee = cursor.getDouble(cursor.getColumnIndex("Fee"));String Time = cursor.getString(cursor.getColumnIndex("Time"));String Remarks = cursor.getString(cursor.getColumnIndex("Remarks"));String Type = cursor.getString(cursor.getColumnIndex("Type"));row = sheet.createRow(number + 1);for (int i = 0; i < 6; i++) {IDCell = row.createCell(i);IDCell.setCellType(HSSFCell.CELL_TYPE_STRING);switch (i) {case 0:IDCell.setCellValue(ID);break;case 1:IDCell.setCellValue(Type);break;case 2:IDCell.setCellValue(Time);break;case 3:IDCell.setCellValue(Fee);break;case 4:IDCell.setCellValue(Remarks);break;case 5:IDCell.setCellValue(budget);break;default:break;}}cursor.moveToNext();number++;}cursor.close();mDataBase.close();mMysql.close();// 新建一输出文件流FileOutputStream fOut = new FileOutputStream(sdCardRoot + outputFile);// 把相应的Excel 工作簿存盘workbook.write(fOut);fOut.flush();// 操作结束,关闭文件fOut.close();workbook.close();//消息通知栏//定义NotificationManagerString ns = Context.NOTIFICATION_SERVICE;NotificationManager mNotificationManager = (NotificationManager) getActivity().getSystemService(ns);//定义通知栏展现的内容信息int icon = R.drawable.back;CharSequence tickerText = "通知栏";long when = System.currentTimeMillis();Notification notification = new Notification(icon, tickerText, when);//定义下拉通知栏时要展现的内容信息Context context = getActivity().getApplicationContext();CharSequence contentTitle = "已经导出数据";CharSequence contentText = "点击查看文件";File path = new File(Environment.getExternalStorageDirectory().getPath());Intent notificationIntent = new Intent(Intent.ACTION_GET_CONTENT);notificationIntent.setDataAndType(Uri.fromFile(file), "Finance/");PendingIntent contentIntent = PendingIntent.getActivity(getActivity(), 0,notificationIntent, 0);notification.setLatestEventInfo(context, contentTitle, contentText,contentIntent);//用mNotificationManager的notify方法通知用户生成标题栏消息通知mNotificationManager.notify(1, notification);vibrator = (Vibrator)getActivity().getSystemService(Context.VIBRATOR_SERVICE);long [] pattern = {100,400,100,400};   // 停止 开启 停止 开启vibrator.vibrate(pattern, -1);} catch (Exception e) {Toast.makeText(getActivity(), "写入失败" + e, Toast.LENGTH_LONG).show();} finally {//  Toast.makeText(getActivity(), "关闭", Toast.LENGTH_LONG).show();}}
}

目前完成的主要是这两个界面的功能。

现在介绍下关于记账界面代码:
BillsActivity.java,主要从数据库获得数据,并通过listview显示。常按能够删除账单条目。

package com.bank;import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import android.view.ContextMenu;
import android.view.MotionEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;import java.util.ArrayList;
import java.util.HashMap;/*** Created by zhouchenglin on 2016/4/1.*/
public class BillsActivity extends Activity implements View.OnClickListener {//列举数据的ListViewprivate ListView mlistbills;// 适配器private SimpleAdapter mlistbillsAdapter;//数据库private MySQLiteHelper mMysql;private SQLiteDatabase mDataBase;private ImageView imageviewback;// 存储数据的数组列表ArrayList<HashMap<String, Object>> listData = new ArrayList<HashMap<String, Object>>();public void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.bills);mlistbills = (ListView) this.findViewById(R.id.list_bills);imageviewback = (ImageView) this.findViewById(R.id.imageviewBack);imageviewback.setOnClickListener(this);GetData();mlistbillsAdapter = new SimpleAdapter(this,listData,R.layout.billsitem,new String[]{"Time", "Type", "Fee", "Remarks"},new int[]{R.id.texttimeshow, R.id.imagetypeshow, R.id.textfeeshow, R.id.textremarksshow});//赋予数据mlistbills.setAdapter(mlistbillsAdapter);//常按响应mlistbills.setOnCreateContextMenuListener(listviewLongPress);//点击事件//  mlistbills.setOnItemClickListener(listviewClick);
//                mlistbills.setOnItemClickListener(listviewClick);
//
//                mlistbills.setOnItemLongClickListener(listviewLongClick);mlistbills.setOnTouchListener(onTouchListener);}View.OnTouchListener onTouchListener = new View.OnTouchListener() {float x, y, ux, uy;@Overridepublic boolean onTouch(View v, MotionEvent event) {// TODO Auto-generated method stubswitch (event.getAction()) {case MotionEvent.ACTION_DOWN:x = event.getX();y = event.getY();break;case MotionEvent.ACTION_UP:ux = event.getX();uy = event.getY();int p2 = ((ListView)v).pointToPosition((int) ux, (int) uy);return false;}return false;}};AdapterView.OnItemLongClickListener listviewLongClick = new AdapterView.OnItemLongClickListener() {@Overridepublic boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {return false;}};AdapterView.OnItemClickListener listviewClick = new AdapterView.OnItemClickListener() {@Overridepublic void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {Toast.makeText(getApplicationContext(),"weffwe", Toast.LENGTH_SHORT).show();}};//从数据库获得适配器数据public void GetData() {mMysql = new MySQLiteHelper(this, "finance.db", null, 1);mDataBase = mMysql.getReadableDatabase();Cursor cursor = mDataBase.rawQuery("select * from finance order by ID DESC ", null);cursor.moveToFirst();int columnsSize = cursor.getColumnCount();int number = 0;while (number < cursor.getCount()) {//  cursor.move(i);HashMap<String, Object> map = new HashMap<String, Object>();String budget = cursor.getString(cursor.getColumnIndex("Budget"));map.put("ID", cursor.getString(cursor.getColumnIndex("ID")));map.put("Fee", cursor.getDouble(cursor.getColumnIndex("Fee")));map.put("Time", cursor.getString(cursor.getColumnIndex("Time")));if (budget.equals("收入"))map.put("Fee", "+" + cursor.getString(cursor.getColumnIndex("Fee")));elsemap.put("Fee", "-" + cursor.getString(cursor.getColumnIndex("Fee")));map.put("Remarks", cursor.getString(cursor.getColumnIndex("Remarks")));if ((cursor.getString(cursor.getColumnIndex("Type"))).equals("衣")) {map.put("Type", R.drawable.cloth);} else if ((cursor.getString(cursor.getColumnIndex("Type"))).equals("食")) {map.put("Type", R.drawable.shi);} else if ((cursor.getString(cursor.getColumnIndex("Type"))).equals("住")) {map.put("Type", R.drawable.zhu);} else if ((cursor.getString(cursor.getColumnIndex("Type"))).equals("行")) {map.put("Type", R.drawable.xing);} else if ((cursor.getString(cursor.getColumnIndex("Type"))).equals("其他")) {map.put("Type", R.drawable.getmoney);}cursor.moveToNext();listData.add(map);number++;System.out.println(listData);}cursor.close();mDataBase.close();mMysql.close();}@Overridepublic void onClick(View view) {switch (view.getId()) {case R.id.imageviewBack:this.finish();break;default:break;}}// 长按事件响应View.OnCreateContextMenuListener listviewLongPress = new  View.OnCreateContextMenuListener() {@Overridepublic void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {// TODO Auto-generated method stubfinal AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;new AlertDialog.Builder(BillsActivity.this)/* 弹出窗口的最上头文字 */.setTitle("删除当前数据")/* 设置弹出窗口的图式 */.setIcon(android.R.drawable.ic_dialog_info)/* 设置弹出窗口的信息 */.setMessage("确定删除当前记录").setPositiveButton("是",new DialogInterface.OnClickListener() {public void onClick(DialogInterface dialoginterface, int i) {// 获取位置索引int mListPos = info.position;// 获取对应HashMap数据内容HashMap<String, Object> map = listData.get(mListPos);// 获取idint id = Integer.valueOf((map.get("ID").toString()));// 获取数组具体值后,可以对数据进行相关的操作,例如更新数据String[] whereArgs = new String[]{String.valueOf(id)};//获取当前数据库mMysql = new MySQLiteHelper(BillsActivity.this, "finance.db", null, 1);mDataBase = mMysql.getReadableDatabase();try {mDataBase.delete("Finance", "ID=?", whereArgs);listData.remove(mListPos);mlistbillsAdapter.notifyDataSetChanged();} catch (Exception e) {Log.e("删除出错了", "error");} finally {mDataBase.close();mMysql.close();}}}).setNegativeButton("否",new DialogInterface.OnClickListener() {public void onClick(DialogInterface dialoginterface, int i) {}}).show();}};}

RecorderActivity.java
主要功能是添加账目,记录自己的消费。

package com.bank;import android.app.Activity;
import android.app.DatePickerDialog;
import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TextView;import java.util.ArrayList;
import java.util.Calendar;public class RecorderActivity extends Activity implements View.OnClickListener {private Button mbutton_sure, mbutton_cancel;private Spinner mspinner_type;private EditText  medittext_fee, medittext_remarks;private TextView  medittext_time;private RadioGroup mRadiogroup;private MySQLiteHelper mMysql;private SQLiteDatabase mDataBase;private ImageButton imageButtonBack;// 用来装日期的private Calendar calendar;//日历控件private DatePickerDialog dialog;//保存类型数据private String content_type, content_select_group;private ArrayList<String> Data = new ArrayList<String>();public void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.recorder);//获得控件mbutton_sure             = (Button) findViewById(R.id.plan_sure);mbutton_cancel           = (Button) findViewById(R.id.button_cancel);medittext_time           = (TextView) findViewById(R.id.edit_text_time);medittext_fee           = (EditText) findViewById(R.id.editText_fee);medittext_remarks       = (EditText) findViewById(R.id.editText_remarks);mbutton_sure             = (Button) findViewById(R.id.plan_sure);mspinner_type           = (Spinner) findViewById(R.id.spinner_type);mRadiogroup              = (RadioGroup) this.findViewById(R.id.radioGroup);imageButtonBack         = (ImageButton) this.findViewById(R.id.imageButtonBack);//设置Spinner的数据并操作ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,R.array.Select_item, android.R.layout.simple_spinner_item);adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);//将数据和spinner控件绑定在一起mspinner_type.setAdapter(adapter);medittext_time.setOnClickListener(this);imageButtonBack.setOnClickListener(this);mspinner_type.setOnItemSelectedListener(listener);mRadiogroup.setOnCheckedChangeListener(grouplistener);mbutton_sure.setOnClickListener(this);mbutton_cancel.setOnClickListener(this);}//单选按钮点击响应RadioGroup.OnCheckedChangeListener grouplistener = new RadioGroup.OnCheckedChangeListener() {@Overridepublic void onCheckedChanged(RadioGroup arg0, int arg1) {// TODO Auto-generated method stub//获取变更后的选中项的IDint radioButtonId = arg0.getCheckedRadioButtonId();//根据ID获取RadioButton的实例content_select_group = (((RadioButton) findViewById(radioButtonId)).getText()).toString();}};//spinner控件的响应事件AdapterView.OnItemSelectedListener listener = new AdapterView.OnItemSelectedListener() {public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {// An item was selected. You can retrieve the selected item usingcontent_type = mspinner_type.getItemAtPosition(pos).toString();//     Toast.makeText(getActivity(), "选中了"+content_type, Toast.LENGTH_LONG).show();}public void onNothingSelected(AdapterView<?> parent) {// Another interface callback}};//视图组件点击时间@Overridepublic void onClick(View view) {switch (view.getId()) {case R.id.plan_sure:Data.clear();Data.add(content_type);Data.add(medittext_time.getText().toString());Data.add(medittext_fee.getText().toString());Data.add(medittext_remarks.getText().toString());Data.add(content_select_group);//    Toast.makeText(getActivity(), "click sure button" + Data, Toast.LENGTH_LONG).show();WriteData(Data);//   Toast.makeText(getActivity(), "click sure button" + Data, Toast.LENGTH_LONG).show();break;case R.id.button_cancel://     GetData()this.finish();break;case R.id.imageButtonBack:this.finish();break;case R.id.edit_text_time:calendar = Calendar.getInstance();dialog = new DatePickerDialog(this,new DatePickerDialog.OnDateSetListener() {@Overridepublic void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {calendar.set(year, monthOfYear, dayOfMonth);medittext_time.setText(DateFormat.format("yyy-MM-dd", calendar));}},calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH),calendar.get(Calendar.DAY_OF_MONTH));dialog.show();break;default:break;}}public void WriteData(ArrayList<String> Data){mMysql = new MySQLiteHelper(this, "finance.db", null, 1);mDataBase = mMysql.getReadableDatabase();ContentValues cv=new ContentValues();cv.put("Type",Data.get(0));cv.put("Time",Data.get(1));cv.put("Fee",Data.get(2));cv.put("Remarks",Data.get(3));cv.put("Budget",Data.get(4));mDataBase.insert("finance", "Type", cv);mDataBase.close();mMysql.close();//结束当前activitythis.finish();}
}

MySQLiteHelper.java 数据库操作的辅助类。

package com.bank;import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Environment;
import android.util.Log;import java.io.File;/*** Created by zhouchenglin on 2016/3/28.*/
public class MySQLiteHelper extends SQLiteOpenHelper {//抽象类必须调用父类方法public MySQLiteHelper(Context context, String name, CursorFactory factory, int version) {//调用父类构造函数super(context, getMyDatabaseName(name), factory, version);}private static String getMyDatabaseName(String name){String databasename = name;boolean isSdcardEnable = false;String state = Environment.getExternalStorageState();if(Environment.MEDIA_MOUNTED.equals(state)){//SDCard是否插入isSdcardEnable = true;}String dbPath = null;if(isSdcardEnable){dbPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Finance/database/";}else{//未插入SDCard,建在内存中}File dbp = new File(dbPath);if(!dbp.exists()){dbp.mkdirs();}databasename = dbPath + databasename;return databasename;}/*** 当数据库首次创建时执行该方法,一般将创建表等初始化操作放在该方法中执行.* 重写onCreate方法,调用execSQL方法创建表*/@Overridepublic void onCreate(SQLiteDatabase db) {Log.i("SWORD", "create a Database");//创建数据库sql语句String sql = "create table finance(ID integer PRIMARY KEY AUTOINCREMENT,Type varchar(10),Time varchar(20),Fee double,Remarks varchar(20),Budget varchar(10))";//执行创建数据库操作db.execSQL(sql);//创建表sql = "create table plan(ID integer PRIMARY KEY AUTOINCREMENT,Morningplan varchar(100),Afternoonplan varchar(100),Nightplan varchar(100),Rank varchar(5), Conclusion varchar(100))";//执行创建数据库操作db.execSQL(sql);}@Override//当打开数据库时传入的版本号与当前的版本号不同时会调用该方法public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {}
}

SubmitDataService.java
主要是同步数据的时候需要用到的服务。

package com.bank;import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Binder;
import android.os.IBinder;
import android.os.Vibrator;import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;/*** Created by zhouchenglin on 2016/4/13.*/
public class SubmitDataService extends Service {private Vibrator vibrator;boolean finishflag =false;//数据库private MySQLiteHelper mMysql;private SQLiteDatabase mDataBase;IBinder  myBinder = new MyBinder();class MyBinder extends Binder {public Service getService(){return SubmitDataService.this;}}@Overridepublic IBinder onBind(Intent intent) {return myBinder;}public boolean getfinishflag(){return finishflag;}//第一次开始的时候执行,或者关闭服务后执行@Overridepublic void onCreate() {super.onCreate();
//                Log.d(TAG, "onCreate() executed");}// 每次开启服务都会执行,重新开启服务都会执行@Overridepublic int onStartCommand(Intent intent, int flags, int startId) {new Thread(new Runnable() {@Overridepublic void run() {// 开始执行后台任务SubmitData();}}).start();return super.onStartCommand(intent, flags, startId);}//销毁服务public void onDestroy() {super.onDestroy();}public void SubmitData() {mMysql = new MySQLiteHelper(this, "finance.db", null, 1);mDataBase = mMysql.getReadableDatabase();Cursor cursor = mDataBase.rawQuery("select * from finance", null);cursor.moveToFirst();int columnsSize = cursor.getColumnCount();int number = 0;while (number < cursor.getCount()) {String budget = cursor.getString(cursor.getColumnIndex("Budget"));int  ID          = cursor.getInt(cursor.getColumnIndex("ID"));Double Fee      =cursor.getDouble(cursor.getColumnIndex("Fee"));String Time      =cursor.getString(cursor.getColumnIndex("Time"));String Remarks = cursor.getString(cursor.getColumnIndex("Remarks"));String Type     =cursor.getString(cursor.getColumnIndex("Type"));String xml = CreateXml(ID,Type,Fee,Time,Remarks,budget);SubmitRequest(xml);cursor.moveToNext();number++;}cursor.close();mDataBase.close();mMysql.close();//消息通知栏//定义NotificationManagerString ns = Context.NOTIFICATION_SERVICE;NotificationManager mNotificationManager = (NotificationManager)getSystemService(ns);//定义通知栏展现的内容信息int icon = R.drawable.back;CharSequence tickerText = "通知栏";long when = System.currentTimeMillis();Notification notification = new Notification(icon, tickerText, when);//定义下拉通知栏时要展现的内容信息Context context = getApplicationContext();CharSequence contentTitle = "已经完成同步";CharSequence contentText = "进入程序查看详情";Intent notificationIntent = new Intent(this, MainActivity.class);PendingIntent contentIntent = PendingIntent.getActivity(this, 0,notificationIntent, 0);notification.setLatestEventInfo(context, contentTitle, contentText,contentIntent);//用mNotificationManager的notify方法通知用户生成标题栏消息通知mNotificationManager.notify(1, notification);vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);long [] pattern = {100,400,100,400};   // 停止 开启 停止 开启vibrator.vibrate(pattern,-1);}public String CreateXml(int ID, String Type, double Fee, String Time, String Remarks, String Budget){String xml = "<?xml version='1.0' encoding='UTF-8'?>"+ "<Data>"+ "<ID>" + ID + "</ID>"+ "<Type>" + Type + "</Type>"+ "<Fee>" + Fee + "</Fee>"+ "<Time>" + Time + "</Time>"+ "<Remarks>" + Remarks + "</Remarks>"+ "<Budget>" + Budget + "</Budget>"+ "</Data>";return xml;}//执行功能的函数public void SubmitRequest(String xml) {try {// 创建url资源URL url = new URL("http://119.29.85.118//finance.php");// 建立http连接HttpURLConnection conn = (HttpURLConnection) url.openConnection();// 设置允许输出conn.setDoOutput(true);conn.setDoInput(true);// 设置不用缓存conn.setUseCaches(false);// 设置传递方式conn.setRequestMethod("POST");// 设置维持长连接conn.setRequestProperty("Connection", "Keep-Alive");// 设置文件字符集:conn.setRequestProperty("Charset", "UTF-8");//转换为字节数组byte[] data = xml.getBytes();// 设置文件长度conn.setRequestProperty("Content-Length", String.valueOf(data.length));// 设置文件类型:conn.setRequestProperty("contentType", "text/xml");// 开始连接请求conn.connect();OutputStream out = conn.getOutputStream();// 写入请求的字符串out.write(data);out.flush();out.close();System.out.println(conn.getResponseCode());// 请求返回的状态if (conn.getResponseCode() == 200) {System.out.println("连接成功");// 请求返回的数据InputStream in = conn.getInputStream();String a = null;try {byte[] data1 = new byte[in.available()];in.read(data1);// 转成字符串a = new String(data1);System.out.println(a);} catch (Exception e1) {// TODO Auto-generated catch blocke1.printStackTrace();}} else {System.out.println("no++");}finishflag =true;} catch (Exception e) {finishflag =false;}}
}

还有服务端代码也给出来,通过操作xml文件来传递数据。
finance.php

<?php$file_in = file_get_contents("php://input");$xml=simplexml_load_string($file_in); ini_set("display_errors", "On");error_reporting(E_ALL | E_STRICT);   $Type ="食";$Time ="2015-02-01";$ID =3;$connection    =mysql_connect("localhost","zhouchenglin","zhouchenglin");if(!$connection){die("不能连接数据库:".mysql_error());} else{echo "连接成功";}if(!mysql_select_db("zhouchenglin",$connection)) {die("Select Database Failed: " . mysql_error($connection));    }else{echo "数据库连接成功";}mysql_query("set names utf8");$sql =sprintf("INSERT INTO `finance`(`ID`,`Type`, `Time`,`Fee`,`Remarks`,`Budget`)VALUES('%d', '%s','%s','%f','%s','%s')",$xml->ID,$xml->Type,$xml->Time,$xml->Fee,$xml->Remarks,$xml->Budget);$res =mysql_query($sql,$connection);if(!$res){            die(mysql_error());         echo '执行失败';}elseecho '执行成功';mysql_close($connection);?>

主要的功能都是通过这些代码实现。我就粘贴几个重要的布局文件。
activity_main.xml

<?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:background="#eee"android:orientation="vertical"android:weightSum="1"><LinearLayout
        android:layout_width="fill_parent"android:layout_height="50dp"android:background="#628fd0"></LinearLayout><android.support.v4.view.ViewPager
        android:id="@+id/id_viewpager"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_weight="0.97"></android.support.v4.view.ViewPager><include layout="@layout/bottom_bar"/></LinearLayout>

bottom_bar.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/ly_main_tab_bottom"android:layout_width="fill_parent"android:layout_height="70dp"android:layout_alignParentBottom="true"android:background="@drawable/tar_bar1" ><!--android:background="@drawable/bottom_bar" >--><LinearLayout
        android:layout_width="fill_parent"android:layout_height="wrap_content" ><LinearLayout
            android:id="@+id/id_tab_bottom_weixin"android:layout_width="0dp"android:layout_height="fill_parent"android:layout_weight="1"android:descendantFocusability="beforeDescendants"android:gravity="center"android:orientation="vertical" ><ImageButton
                android:id="@+id/btn_tab_bottom_weixin"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="#0000"android:clickable="false"android:src="@drawable/tab_weixin_pressed" /><TextView
                android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="账户" /></LinearLayout><LinearLayout
            android:id="@+id/id_tab_bottom_friend"android:layout_width="0dp"android:layout_height="fill_parent"android:layout_weight="1"android:descendantFocusability="beforeDescendants"android:gravity="center"android:orientation="vertical" ><ImageButton
                android:id="@+id/btn_tab_bottom_friend"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="#0000"android:clickable="false"android:src="@drawable/tab_find_frd_normal" /><TextView
                android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="计划详情" /></LinearLayout><LinearLayout
            android:id="@+id/id_tab_bottom_contact"android:layout_width="0dp"android:layout_height="fill_parent"android:layout_weight="1"android:descendantFocusability="beforeDescendants"android:gravity="center"android:orientation="vertical" ><ImageButton
                android:id="@+id/btn_tab_bottom_contact"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="#0000"android:clickable="false"android:src="@drawable/tab_address_normal" /><TextView
                android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="多记计" /></LinearLayout><LinearLayout
            android:id="@+id/id_tab_bottom_setting"android:layout_width="0dp"android:layout_height="fill_parent"android:layout_weight="1"android:descendantFocusability="beforeDescendants"android:gravity="center"android:orientation="vertical" ><ImageButton
                android:id="@+id/btn_tab_bottom_setting"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="#0000"android:clickable="false"android:src="@drawable/tab_settings_normal" /><TextView
                android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="我" /></LinearLayout></LinearLayout></RelativeLayout>

bills.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical"android:background="#FFFFFF"><LinearLayout
        android:layout_width="fill_parent"android:layout_height="50dp"android:id="@+id/linearLayout3"android:orientation="horizontal"android:layout_alignParentTop="true"android:layout_alignParentLeft="true"android:layout_alignParentStart="false"android:background="#444eb9"android:weightSum="1"android:gravity="center_vertical"><ImageView
            android:layout_width="80dp"android:layout_height="30dp"android:id="@+id/imageviewBack"android:src="@drawable/back"android:background="#444eb9"/><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="账单"android:id="@+id/textView2"android:layout_gravity="center_vertical"android:background="#444eb9"android:layout_marginLeft="80dp"android:textColor="#FFFFFF"android:textStyle="bold"android:editable="false"android:enabled="false"android:hint="size"android:textIsSelectable="false"android:textSize="20dp"/></LinearLayout><ListView
        android:id="@+id/list_bills"android:layout_width="wrap_content"android:layout_height="wrap_content"android:divider="#ffffff"android:dividerHeight="1dip"android:layout_below="@+id/linearLayout3"android:layout_alignParentLeft="true"android:layout_alignParentStart="true"android:background="#fbf5f5"/>
</RelativeLayout>

billsitem.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical"><TextView
    android:layout_width="wrap_content"android:layout_height="wrap_content"android:textAppearance="?android:attr/textAppearanceSmall"android:text="no data"android:id="@+id/texttimeshow"android:layout_alignParentTop="true"android:layout_alignParentLeft="true"android:layout_alignParentStart="true"android:layout_marginRight="28dp"android:layout_marginTop="20dp"android:layout_marginLeft="20dp"android:gravity="center"/><ImageView
    android:layout_width="55dp"android:layout_height="55dp"android:id="@+id/imagetypeshow"android:layout_alignParentTop="true"android:layout_toRightOf="@+id/texttimeshow"android:padding="10dp"/><TextView
    android:layout_width="wrap_content"android:layout_height="wrap_content"android:textAppearance="?android:attr/textAppearanceSmall"android:text="no data"android:id="@+id/textfeeshow"android:layout_marginLeft="61dp"android:layout_marginStart="61dp"android:layout_alignParentTop="true"android:layout_alignLeft="@+id/textremarksshow"android:layout_alignStart="@+id/textremarksshow"android:layout_marginTop="10dp"android:gravity="center"/><TextView
    android:layout_width="match_parent"android:layout_height="wrap_content"android:text="Large Text"android:id="@+id/textremarksshow"android:layout_alignBottom="@+id/imagetypeshow"android:layout_toRightOf="@+id/imagetypeshow"android:layout_toEndOf="@+id/imagetypeshow"android:layout_marginLeft="34dp"android:layout_marginStart="34dp"android:gravity="center"/>
</RelativeLayout>

finance_check.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="fill_parent"android:layout_height="fill_parent"><TextView
        android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="余额"android:layout_marginLeft="90dp"android:layout_alignBottom="@+id/textremainder"android:layout_alignParentTop="true"android:layout_marginTop="200dp"android:id="@+id/textView4"/><TextView
        android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="19.8"android:id="@+id/textremainder"android:layout_alignParentTop="true"android:layout_alignParentRight="true"android:layout_alignParentEnd="false"android:layout_alignParentStart="false"android:layout_alignWithParentIfMissing="false"android:layout_alignParentLeft="false"android:layout_marginTop="200dp"android:layout_marginRight="100dp"/><TextView
        android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="当前本月支出"android:id="@+id/textView3"android:layout_below="@+id/textView4"android:layout_alignParentLeft="true"android:layout_alignParentStart="true"android:layout_marginTop="41dp"android:layout_marginLeft="90dp"/><TextView
        android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="500"android:id="@+id/textpay"android:layout_alignTop="@+id/textView3"android:layout_alignLeft="@+id/textremainder"android:layout_alignStart="@+id/textremainder"/><TextView
        android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="本月收入"android:id="@+id/textView6"android:layout_below="@+id/textView3"android:layout_alignParentLeft="true"android:layout_alignParentStart="true"android:layout_marginTop="40dp"android:layout_marginLeft="90dp"/><TextView
        android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="7000"android:id="@+id/textincome"android:layout_alignTop="@+id/textView6"android:layout_alignLeft="@+id/textpay"android:layout_alignStart="@+id/textpay"/></RelativeLayout>

recorder.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="fill_parent"android:layout_height="match_parent"android:background="#e2efd9"><LinearLayout
        android:layout_width="fill_parent"android:layout_height="50dp"android:id="@+id/linearLayout3"android:orientation="horizontal"android:layout_alignParentTop="true"android:layout_alignParentLeft="true"android:layout_alignParentStart="false"android:background="#444eb9"android:weightSum="1"android:gravity="center_vertical"><ImageButton
            android:layout_width="80dp"android:layout_height="30dp"android:id="@+id/imageButtonBack"android:src="@drawable/back"android:background="#444eb9"/><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="记一笔"android:id="@+id/textView2"android:layout_gravity="center_vertical"android:background="#444eb9"android:layout_marginLeft="80dp"android:textColor="#FFFFFF"android:textStyle="bold"android:editable="false"android:enabled="false"android:hint="size"android:textIsSelectable="false"android:textSize="20dp"/></LinearLayout><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="类型"android:id="@+id/texttype"android:layout_gravity="center_horizontal"android:textStyle="bold"android:clickable="false"android:editable="false"android:textColor="#0472f8"android:layout_weight="0.00"android:layout_marginLeft="57dp"android:layout_marginStart="57dp"android:layout_marginTop="24dp"android:layout_below="@+id/radioGroup"android:layout_alignParentLeft="true"android:layout_alignParentStart="true"/><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="时间"android:id="@+id/texttimeshow"android:layout_gravity="center_horizontal"android:textColor="#0472f8"android:layout_below="@+id/texttype"android:layout_toLeftOf="@+id/spinner_type"android:layout_toStartOf="@+id/spinner_type"android:layout_marginTop="44dp"/><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="费用"android:id="@+id/textfeeshow"android:layout_gravity="center_horizontal"android:textColor="#0472f8"android:layout_marginTop="29dp"android:layout_below="@+id/edit_text_time"android:layout_toLeftOf="@+id/spinner_type"android:layout_toStartOf="@+id/spinner_type"/><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="备注"android:id="@+id/textremarksshow"android:layout_gravity="center_horizontal"android:textColor="#0472f8"android:layout_marginTop="27dp"android:layout_below="@+id/editText_fee"android:layout_toLeftOf="@+id/spinner_type"android:layout_toStartOf="@+id/spinner_type"/><Spinner
            android:layout_width="match_parent"android:layout_height="25dp"android:id="@+id/spinner_type"android:spinnerMode="dialog"android:entries="@array/Select_item"android:layout_alignBottom="@+id/texttype"android:layout_toRightOf="@+id/texttype"android:layout_marginLeft="43dp"android:layout_marginRight="50dp"android:gravity="center_vertical|center"android:paddingLeft="50dp"android:touchscreenBlocksFocus="false"android:layout_alignParentLeft="false"style="@android:style/TextAppearance.Holo"/><TextView
            android:id="@+id/edit_text_time"android:layout_width="wrap_content"android:layout_height="40dp"android:background="@android:drawable/edit_text"android:layout_alignTop="@+id/texttimeshow"android:layout_alignLeft="@+id/spinner_type"android:layout_alignStart="@+id/spinner_type"android:layout_alignParentRight="true"android:layout_alignParentEnd="true"android:layout_marginRight="50dp"android:editable="true"android:gravity="center"android:textColor="#736bae"/><EditText
            android:id="@+id/editText_fee"android:editable="true"android:layout_width="match_parent"android:layout_height="40dp"android:background="@android:drawable/edit_text"android:layout_alignTop="@+id/textfeeshow"android:layout_alignLeft="@+id/edit_text_time"android:layout_alignStart="@+id/edit_text_time"android:layout_marginRight="50dp"android:textColor="#fc0303"android:gravity="center"/><EditText
            android:id="@+id/editText_remarks"android:layout_width="fill_parent"android:layout_height="94dp"android:inputType="textMultiLine"android:singleLine="false"android:gravity="left|top"android:width="2dip"android:background="@android:drawable/edit_text"android:layout_alignTop="@+id/textremarksshow"android:layout_alignLeft="@+id/editText_fee"android:layout_alignStart="@+id/editText_fee"android:layout_marginRight="50dp"android:textColor="#5e5b5b"android:textSize="15dp"/><Button
            android:layout_width="50dp"android:layout_height="30dp"android:text="保存"android:id="@+id/plan_sure"android:background="@drawable/buttonshape"android:layout_below="@+id/editText_remarks"android:layout_alignLeft="@+id/texttype"android:layout_alignStart="@+id/texttype"android:layout_marginTop="36dp"android:layout_marginLeft="20dp"/><Button
            android:layout_width="50dp"android:layout_height="30dp"android:text="取消"android:id="@+id/button_cancel"android:background="@drawable/buttonshape"android:layout_alignTop="@+id/plan_sure"android:layout_alignRight="@+id/editText_remarks"android:layout_alignEnd="@+id/editText_remarks"android:layout_marginRight="20dp"/><RadioGroup
        android:layout_width="match_parent"android:layout_height="50dp"android:orientation="horizontal"android:gravity="center_vertical"android:id="@+id/radioGroup"android:layout_below="@+id/linearLayout3"android:layout_alignParentLeft="true"android:layout_alignParentStart="true"android:layout_marginTop="58dp"><RadioButton
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="收入"android:id="@+id/radioButton"android:checked="false"android:layout_below="@+id/linearLayout3"android:layout_alignLeft="@+id/texttimeshow"android:layout_alignStart="@+id/texttimeshow"android:layout_gravity="center_vertical"android:layout_marginLeft="50dp"/><RadioButton
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="支出"android:id="@+id/radioButton2"android:checked="false"android:layout_alignBottom="@+id/radioGroup"android:layout_centerHorizontal="true"android:layout_marginLeft="50dp"/></RadioGroup></RelativeLayout>

主要功能和实现就是这些,希望自己中涉及到的技术以后自己能够用得到。通过观看以前写过的代码来反映自己的成长,这是一个多么令人兴奋的故事。

源码下载地址

Android 练习项目 ——简单记账软件的实现相关推荐

  1. 做简单的android 软件推荐,Android_适用于Android开发的简单聊天软件,适用于android 开发。是一个简 - phpStudy...

    适用于Android开发的简单聊天软件 适用于android 开发.是一个简单的聊天软件,包括知识点,各个控件的运用(ExpandableListView,ViewPager,Spinner,Line ...

  2. Java项目----家庭记账软件(基于文本界面)

    一.涉及要点: ①变量的定义 ②基本数据类的使用 ③循环语句 ④分支语句 ⑤方法声明.调用和返回值的接收 ⑥简单屏幕输出格式控制 二.需求说明 ①能够记录家庭的收入.支出,并能够打印收支明细表 ②采用 ...

  3. Java 小项目 01 简单记账软件

    1 功能介绍 1.1 功能介绍 查询账务 多条件查询 添加账务 编辑账务 删除账务 1.2 运行结果 2 环境搭建 1)开发工具:eclipse 2)第三方jar包 jar 包下载 commons-d ...

  4. android 小项目 简单项目 大作业 演示文档 结业 选修课 论文 答辩

  5. 基于Android开发的记账软件(附带源码)

    该app实现了用户添加删除.用户切换.收入记录.支出记录.查询等功能,适合新手学习.搭建方法请可查看主页中的android相关视频教程. 记账软件文件:url80.ctfile.com/f/25127 ...

  6. android简易记账,简单记账(便捷快速记账)

    简单记账让用户能够快速便捷的进行记账,随时随地的进行记账内容的填充,让你的在生活当中的每一笔花销都能够在这款软件的记录下完成,并且这款软件还比较优秀的点就是用树状图的方式进行时间上面的排列,感兴趣的话 ...

  7. Java项目之家庭记账软件

    项目要求 要求实现一个基于文本界面的记账软件,模拟实现一个基于文本界面的<家庭记账软件>,掌握初步的编程技巧和调试技巧. 主要涉及以下知识点: - 局部变量和基本数据类型 - 循环语句 - ...

  8. 项目一. 家庭记账软件

    要求: 项目一 家庭记账软件 目 标• 模拟实现一个基于文本界面的<家庭记账软件>• 掌握初步的编程技巧和调试技巧• 主要涉及以下知识点: 变量的定义 基本数据类型的使用 循环语句 ...

  9. 基于android的记账软件,基于Android的记账软件的设计与实现

    摘要: 随着经济社会的发展,人们的资金流动更加频繁,对记账的需求也逐渐提高.目前移动设备已经普及,移动记账以其随时随地记账,高效统计的特点,受到了广大记账理财人士的青睐.本文通过对国内外手机记账软件发 ...

最新文章

  1. autofac 用法总结
  2. swagger的php配置,thinkphp6+swagger-php配置管理接口文档
  3. MCU提高ADC采样精度的几种方案
  4. 关于Services.exe开机CPU内存使用暴增解决方案
  5. (134)FPGA面试题-介绍冯·诺依曼体系结构和哈佛体系结构
  6. Visual Studio 安装失败
  7. 深入Managed DirectX9
  8. 临时更换swap优先级
  9. 你的核心竞争力真的是技术么?
  10. 方方格子access_FX Console(AE工作流程插件)
  11. iPhone5/iPad4越狱后10.3.3降级8.4.1详细教程
  12. 5G无线技术基础自学系列 | 5G信道结构
  13. SeaWeedFS文件存储服务器搭建
  14. 手动打开与关闭软键盘
  15. F - Endless Walk
  16. java poi 操作Excel 删除行内容和直接删除行
  17. html版api文档,将html版API文档转换成chm格式的API文档
  18. Spring Boot 要怎么学?要学哪些东西?要不要先学 SSM?松哥说说看法
  19. 2017 Android github上优秀开源项目分类汇总
  20. wallpaper怎么改后缀_怎么让家里无线网速变快

热门文章

  1. CPU的主频/核心数
  2. web app 第三方登录-微博登录(一)
  3. 磁场检测传感器的设计
  4. 解决Win7缺失MSVCR120.DLL问题
  5. windows 10 git bash 提速方法
  6. vue 动态显示图片报错 404
  7. EXCEL之工资表转工资条
  8. Windows bat 编程基本语法
  9. 重磅消息:微信支付分最新开通方法!
  10. 腾讯云 8核 16G 18M 的轻量应用服务器评测