首页 技术 正文
技术 2022年11月13日
0 收藏 871 点赞 2,589 浏览 3251 个字

这个ColaBox记事本是我从网上下载下来的拿来学习一下的(APK下载点这里。)

从登记收入与开支的页面跳转到账单页面运用了SQL数据库的录入,整体表的结构为:

db.execSQL("CREATE TABLE bills ("
+ "_id INTEGER primary key autoincrement,"//ID
+" acctitemid integer,"//账目类型
+ "fee integer,"//费用
+ "userid integer,"//使用者
+ "sdate TEXT,"//日期
+ "stime TEXT,"//时间
+ "desc TEXT" // 备注
+ ");");
Android中的PID:顾名思义,它指的是Process的id。每个进程都有一个独立的id,可以通过pid来区分不同的进程。
在网上把进程PID常用的API搜了一下记录于此:
android.os.Process.myPid( )
得到当前进程的pid
android.os.Process.killProcess ( int pid )
杀死相应进程号的进程
List<ActivityManager.RunningProcessInfo> getRunningAppProcesses( )
获取当前正在运行的进程
android.app.ActivityManager.RunningAppProcessInfo.pid
相应的RunningAppProcessInfo的pid
List<ActivityManager.RunningServiceInfo> getRunningServices ( int maxNum )
得到当前正在运行的ServiceInfo
android.app.ActivityManager.RunningServiceInfo.pid
相应的RunningServiceInfo的pid
而UID是应用在在Android中数据共享中,不同的应用有不同的UID,在Android中要实现UID共享数据只需在程序a,b中的menifest配置即可:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.perseus.a"
      android:versionCode=""
      android:versionName="1.0"
android:sharedUserId="com.share"
>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.perseus.b"
      android:versionCode=""
      android:versionName="1.0"
android:sharedUserId="com.share"
>
   db.execSQL("CREATE TABLE acctitem ("
+ "_ID INTEGER PRIMARY KEY,"//ID
+ "PID integer,"//PID
+ "NAME TEXT" // 姓名
+ ");");
账目表:
 db.execSQL("insert into acctitem values (1,null,'收入')");
db.execSQL("insert into acctitem values (2,1,'工资')");
db.execSQL("insert into acctitem values (9998,1,'其他')");
db.execSQL("insert into acctitem values (0,null,'支出')");
db.execSQL("insert into acctitem values (3,0,'生活用品')");
db.execSQL("insert into acctitem values (4,0,'水电煤气费')");
db.execSQL("insert into acctitem values (5,0,'汽油费')");
db.execSQL("insert into acctitem values (9999,0,'其他')");
主类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();
//通过Handler运行线程所传递的信息
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之记账本

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,112
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,585
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,431
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,203
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,838
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,922