OnCheckChanged 我想检查isChecked 计时器开始和完成时我想将其关闭并停止按钮
if(isChecked){
//on
timer.start();
Client myClient= new Client(serverIP,serverPort,t1,"h");
myClient.execute();
String data=t1.getText().toString();
Toast.makeText(getContext(),data,Toast.LENGTH_LONG).show();
buttonView.setText("On irrigation");
Toast.makeText(getContext(), "Irrigation On" + getItem(position), Toast.LENGTH_SHORT).show();
if(time==0)
{
buttonView.setChecked(false);
myClient= new Client(serverIP,serverPort,t1,"g");
myClient.execute();
data=t1.getText().toString();
}
答案 0 :(得分:1)
只需使用 new CountDownTimer(30000, 1000) {
public void onTick(long millisUntilFinished) {
// Here whatever you want to process in the mean time.
mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
}
public void onFinish() {
// Here you can set your button to off state.
}
}.start();
计时器:
{{1}}