十天冲刺-04

昨天对记一笔的数据库进行了添加,在数据库中运用了主键的自增功能。

遇到的问题由于自己的原因将函数写在了另一个类里,导致后续程序出错软件闪退,后来经过修改之后才得以正常运行

今天把准备剩余功能全部实现,然后着手做额度提醒

 

 public void onCreate(SQLiteDatabase db) {
        Log.i("tag","------onCreate-----");
        String sql="create table student (id Integer primary key autoincrement ,account varchar(10),year varchar(10),month varchar(10),day varchar(10),money varchar(10),type varchar(10))";

        db.execSQL(sql);//执行SQL语句
    }

  

 

    ContentValues values = new ContentValues();
values.put(Constant_person.ACCOUNT, account);
values.put(Constant_person.MONEY, m1);
values.put(Constant_person.TYPE, t1);
values.put(Constant_person.YEAR, year);
values.put(Constant_person.MONTH, month);
values.put(Constant_person.DAY, day);
long result = db.insert(Constant_person.TABLE, null, values);
if (result > 0) {
Toast.makeText(addactivity.this, "记账成功", Toast.LENGTH_LONG).show();
Intent intent = new Intent();
intent.setClass(addactivity.this, loginactivity.class);
intent.putExtra("user", account);
startActivity(intent);
} else {
Toast.makeText(addactivity.this, "记账失败", Toast.LENGTH_LONG).show();
}

}

// });

// }

public void click(View view) {
switch (view.getId()) {
case R.id.food: {
t1 = "餐饮";
// type.setText(t1);
break;
}

case R.id.shop: {
t1 = "购物";
// type.setText(t1);
break;
}
case R.id.trafic: {
t1 = "交通";
// type.setText(t1);
break;
}
case R.id.entertainment: {
t1 = "娱乐";
break;
}
case R.id.clothes: {
t1 = "服装";
break;
}
case R.id.travel: {
t1 = "旅行";
break;
}
case R.id.medicine: {
t1 = "医疗";
break;
}
case R.id.book: {
t1 = "书籍";
break;
}
case R.id.use: {
t1 = "日用";
break;
}
}
type.setText(t1);

}

  

posted on 2019-04-24 07:31  一往无前!  阅读(144)  评论(0编辑  收藏  举报