Beispiel #1
0
  /** 保存数据到数据库 */
  private void saveData() {
    sqlState = ckbModel.isChecked() ? 1 : 0; // 保存闹钟模式状态码
    sqlHour = hours.getCurrentItem();
    sqlMinute = mins.getCurrentItem();
    sqlMusic = "sys.mp3";
    AlarmDao dao = new AlarmDao(AddActivity.this);
    try {

      dao.openDB();
      boolean falg = dao.insertData(sqlHour, sqlMinute, sqlWeekData, sqlMusic, sqlState, 1);
      if (falg) {
        Toast.makeText(this, "闹钟添加成功", Toast.LENGTH_SHORT).show();
      } else {
        Toast.makeText(this, "添加失败", Toast.LENGTH_SHORT).show();
      }
    } catch (Exception e) {
      // TODO: handle exception
      Log.e("添加闹钟", e.getMessage());
    } finally {
      dao.relese();
    }
  }
Beispiel #2
0
  public void init() {

    txtweek = (TextView) findViewById(R.id.setweek);
    txtvoice = (TextView) findViewById(R.id.setvoice);
    btnsave = (ImageButton) findViewById(R.id.save);
    btnback = (ImageButton) findViewById(R.id.back);
    ckbModel = (CheckBox) findViewById(R.id.ckbModel);

    hours = (CustomTimePick) findViewById(R.id.hour);
    hours.setAdapter(new NumericTMAdapter(0, 23));
    mins = (CustomTimePick) findViewById(R.id.mins);
    mins.setAdapter(new NumericTMAdapter(0, 59));
    // 设置滑轮是否循环
    hours.setCyclic(true);
    mins.setCyclic(true);

    Calendar c = Calendar.getInstance();
    int curHours = c.get(Calendar.HOUR_OF_DAY);
    int curMinutes = c.get(Calendar.MINUTE);
    hours.setCurrentItem(curHours);
    mins.setCurrentItem(curMinutes);

    adapter = new DisListAdapter(AddActivity.this, overalllist);

    btnback.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            finish();
          }
        });
    btnsave.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            saveData();
            int id = findId();
            setAlarm(id);
            finish();
          }
        });
    txtweek.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            initWeekDialog();
          }
        });
  }