コード例 #1
0
 // 初始化各个按钮的文本信息
 void initButtonText() {
   timeButton.setText(
       "闹钟时间: "
           + param.getHour()
           + ":"
           + (param.getMinute() > 9 ? param.getMinute() : ("0" + param.getMinute())));
   clockNameButton.setText("闹钟名称: " + param.getName());
   clockCircleButton.setText("闹钟周期: " + param.getRepeatInfo(param.getRepeat()));
   levelButton.setText("闹钟难度: " + (param.getLevel() == 1 ? "简单-加法" : "困难-乘法"));
   vibrateButton.setText(param.isIsvabrate() ? "震动: 开启" : "震动: 关闭");
   String s = param.getAudiotype();
   System.out.println("getAudiotype:" + s);
   if (s.equals("default")) s = "默认";
   else {
     String[] name = s.split("/");
     s = name[name.length - 1];
   }
   musicButton.setText("铃声: " + s);
 }
コード例 #2
0
 // 选择闹钟铃声的Dialog,若选择默认 则设置为软件默认铃声
 // 选择自定义的话,弹出SD卡的文件列表(调用SelectMusicActivity),从中选择符合格式的作为铃声
 void selectMusic() {
   int index = param.getAudiotype().equals("default") ? 0 : 1;
   new AlertDialog.Builder(this)
       .setTitle("  选择闹铃铃声   ")
       .setIcon(android.R.drawable.ic_dialog_info)
       .setSingleChoiceItems(
           new String[] {"默认铃声", "自定义铃声"},
           index,
           new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int which) {
               if (which == 0) {
                 param.setAudiotype("default");
                 musicButton.setText("铃声: 默认");
               } else {
                 Intent intent = new Intent(EditClockActivity.this, SelectMusicActivity.class);
                 startActivityForResult(intent, REQUEST_CODE);
               }
               dialog.dismiss();
             }
           })
       .setNegativeButton("取消", null)
       .show();
 }