我想在计时器完成后关闭按钮

时间:2016-05-23 12:13:56

标签: android

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();

                        }

1 个答案:

答案 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}}