个人冲刺-06
昨天完成了实现了记一笔的所有功能
遇到的问题,在进行与团队的代码整合时出错
今天准备学习将数据库内容成功显示在界面上
public void add() { final SQLiteDatabase db = helper_person.getWritableDatabase(); money = (EditText) findViewById(R.id.money); m1 = money.getText().toString(); type = (TextView)findViewById(R.id.type); t1 = type.getText().toString(); String year = getIntent().getStringExtra("year"); String month = getIntent().getStringExtra("month"); String day = getIntent().getStringExtra("day"); String account = getIntent().getStringExtra("account"); // ty.setOnClickListener(new View.OnClickListener() { // 通过单选框的形式处理消费类型 // @SuppressLint("ResourceType") // @Override // public void onClick(View v) { // String money = editText.getText().toString(); // if (net_shop.isChecked()) { // type = "网上购物"; // } else if (food.isChecked()) { // type = "食堂消费"; // } else if (supermarket.isChecked()) { // type = "超市购物"; // } 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); }