Android 练习项目 ——简单记账软件的实现

原创 2016年04月18日 17:27:00

一、需求分析

在我们生活中经常不知道钱花在什么地方,但是我们自己又不是很想写在记账本上进行管理,由于智能手机的兴起,手机离我们越来越近,导致我们生活时时刻刻都有手机的存在,所以说手机的操作离我们越来越近,趋势越来越明显。但是对于记账,我们往往每个人都有自己的需求,所以对于自己来说,开发一个简单的软件来记账是个非常好玩且有趣的事情。
所以自己趁着学习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;


        @Override
        protected 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()) {

                        @Override
                        public int getCount() {
                                return mFragments.size();
                        }

                        @Override
                        public Fragment getItem(int arg0) {
                                return mFragments.get(arg0);
                        }
                };

                mViewPager.setAdapter(mAdapter);

                mViewPager.addOnPageChangeListener(new OnPageChangeListener() {
                        private int currentIndex;

                        @Override
                        public 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;
                        }

                        @Override
                        public void onPageScrolled(int arg0, float arg1, int arg2) {

                        }

                        @Override
                        public 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;


        @Override
        public 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;


    @Override
    public 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;
    }

    @Override
    public 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参数为tinyphp
                bundle.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:
                //消息通知栏
                //定义NotificationManager
                String 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();

            //消息通知栏
            //定义NotificationManager
            String 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 {

        //列举数据的ListView
        private 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;
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                        // TODO Auto-generated method stub
                        switch (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() {
                @Override
                public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                        return false;
                }
        };

                AdapterView.OnItemClickListener listviewClick = new AdapterView.OnItemClickListener() {
                        @Override
                        public 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")));
                                else
                                        map.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();
                }

                @Override
                public void onClick(View view) {
                        switch (view.getId()) {
                                case R.id.imageviewBack:
                                        this.finish();
                                        break;
                                default:
                                        break;
                        }

                }

                // 长按事件响应
                 View.OnCreateContextMenuListener listviewLongPress = new  View.OnCreateContextMenuListener() {
                        @Override
                        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
                                // TODO Auto-generated method stub
                                final 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);
                                                                // 获取id
                                                                int 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() {
                @Override
                public void onCheckedChanged(RadioGroup arg0, int arg1) {
                        // TODO Auto-generated method stub
                        //获取变更后的选中项的ID
                        int 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 using
                        content_type = mspinner_type.getItemAtPosition(pos).toString();
                        //     Toast.makeText(getActivity(), "选中了"+content_type, Toast.LENGTH_LONG).show();
                }

                public void onNothingSelected(AdapterView<?> parent) {
                        // Another interface callback
                }
        };
        //视图组件点击时间
        @Override
        public 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() {
                                                @Override
                                                public 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();
                //结束当前activity
                this.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方法创建表
         */
        @Override
        public 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;
        }
    }

    @Override
    public IBinder onBind(Intent intent) {
        return myBinder;
    }

    public boolean getfinishflag()
    {
        return finishflag;
    }

    //第一次开始的时候执行,或者关闭服务后执行
    @Override
    public void onCreate() {
        super.onCreate();
//                Log.d(TAG, "onCreate() executed");
    }

    // 每次开启服务都会执行,重新开启服务都会执行
    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        new Thread(new Runnable() {
            @Override
            public 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();
        //消息通知栏
        //定义NotificationManager
        String 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 block
                    e1.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 '执行失败';
         }
        else
            echo '执行成功';

       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 — 个人简洁记账本项目开发日志

个人小项目 - 简洁记账软件
  • dramlee
  • dramlee
  • 2016年07月28日 20:26
  • 2934

Delphi7高级应用开发随书源码

  • 2003年04月30日 00:00
  • 676KB
  • 下载

Delphi7高级应用开发随书源码

  • 2003年04月30日 00:00
  • 676KB
  • 下载

Android源码分享之一-----练手项目

Android项目源码分享 给大家分享几个Android开发项目源码,大部分功能相信可以在实战项目中直接使用,供大家下载学习,大部分项目是基于 Android Studio开发,IDE为E...

Delphi7高级应用开发随书源码

  • 2003年04月30日 00:00
  • 676KB
  • 下载

Delphi7高级应用开发随书源码

  • 2003年04月30日 00:00
  • 676KB
  • 下载

【Android 进阶】CSDN新闻类客户端-练手项目

无图无真相: 声明:本项目数据全部来自CSDN官网,纯练手之作,个人未从中获取任何利益,数据的获取与共享可能会侵犯到CSDN的权益,若被告知需停止共享与使用,本人会立即删除整个项目。项目主要由如...

Delphi7高级应用开发随书源码

  • 2003年04月30日 00:00
  • 676KB
  • 下载

Delphi7高级应用开发随书源码

  • 2003年04月30日 00:00
  • 676KB
  • 下载

一个记账易app开发

主要完成记账,语音记账,短信拦截,录音记账,查找字典,图表统计功能。带登录注册,备份同步功能 完成一个完整的记账app 效果图如下:...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Android 练习项目 ——简单记账软件的实现
举报原因:
原因补充:

(最多只允许输入30个字)