我正在尝试分配用户输入到编辑文本中的值作为倒计时器的起始值,将其转换为毫秒
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
minutes = (EditText) findViewById(R.id.minutes);
seconds = (EditText) findViewById(R.id.seconds);
start = (Button) findViewById(R.id.startbutton);
count = (TextView) findViewById(R.id.counting);
final String sec = String.valueOf(seconds.getText());
int sec1 = Integer.valueOf(sec);
long sec2 = sec1;
//String minu = minutes.getText().toString();
final CountDownTimer counting = new
CountDownTimer(TimeUnit.SECONDS.toMillis(sec2), 1000) {
@Override
public void onTick(long millisUntilFinished) {
Log.i("alarm rings in",
String.valueOf(millisUntilFinished/1000));
}
@Override
public void onFinish() {
Log.i("done", "alarm is ringing");
}
};
start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
counting.start();
}
});
}
}
我期望单击按钮后开始倒计时,但它显示 Onfinish() 方法输出
喵喔喔
猛跑小猪
相关分类