码迷,mamicode.com
首页 > 移动开发 > 详细

Android之记账本

时间:2016-05-29 10:58:25      阅读:283      评论:0      收藏:0      [点我收藏+]

标签:

ColaBox记事本从登记收入与开支跳转到账单页面运用了SQL录入,表的结构为:

db.execSQL("CREATE TABLE bills ("
                    + "_id INTEGER primary key autoincrement,"//ID
                    +" acctitemid integer,"//账目类型   
                    + "fee integer,"//费用
                    + "userid integer,"//使用者
                    + "sdate TEXT,"//日期
                    + "stime TEXT,"//时间
                    + "desc TEXT"    //  备注          
                    + ");");
主类ColaBox:
package com.cola.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.ImageView;
import android.widget.TextView;

public class ColaBox extends Activity {
    private Handler mHandler = new Handler();

    ImageView imageview;
    TextView textview;
    int alpha = 255;
    int b = 0;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        imageview = (ImageView) this.findViewById(R.id.ImageView01);
        textview = (TextView) this.findViewById(R.id.TextView01);

        Log.v("ColaBox", "ColaBox start ...");
        imageview.setAlpha(alpha);

        new Thread(new Runnable() {
            public void run() {
                initApp();
                
                while (b < 2) {
                    try {
                        if (b == 0) {
                            Thread.sleep(1000);
                            b = 1;
                        } else {
                            Thread.sleep(50);
                        }

                        updateApp();

                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

            }
        }).start();

        mHandler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                super.handleMessage(msg);
                imageview.setAlpha(alpha);
                imageview.invalidate();


            }
        };

    }

    public void updateApp() {
        alpha -= 5;

        if (alpha <= 0) {
            b = 2;
            Intent in = new Intent(this, com.cola.ui.Frm_Addbills.class);
            startActivity(in);
            this.finish();
        }

        mHandler.sendMessage(mHandler.obtainMessage());

    }
    
    public void initApp(){
         BilldbHelper billdb=new BilldbHelper(this);
           billdb.FirstStart();          
           billdb.close();
           
           
    }

    public boolean onKeyDown(int keyCode, KeyEvent event) {
        Log.v("cola", "keycode=" + keyCode);
        switch (keyCode) {
        case KeyEvent.KEYCODE_BACK:
            Log.v("ColaBox", "ColaBox end ...");
            return true;
            
        }
        return false;
    }
}

 

运行效果:

技术分享

Android之记账本

标签:

原文地址:http://www.cnblogs.com/caidupingblogs/p/5538965.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!