如何把倒数计时器 [英] How to put countdown timer

查看:93
本文介绍了如何把倒数计时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题游戏,有时间限制。我怎么能code。如果别人=如果他回答是正确的,他会有意到新的水平,如果他没有在10秒他会故意在另一个班级一一解答

  @覆盖
公共无效的onCreate(包savedInstanceState){
    super.onCreate(savedInstanceState);
    的setContentView(R.layout.easyone);
    A1 =(按钮)findViewById(R.id.btn_ea1);
    B1 =(按钮)findViewById(R.id.btn_eb1);
    C1 =(按钮)findViewById(R.id.btn_ec1);

    a1.setOnClickListener(新View.OnClickListener(){

        @覆盖
           公共无效的onClick(视图v){
                Toast.makeText(getApplicationContext(),正确!
                        Toast.LENGTH_SHORT).show();
                意向意图=新的意图(getApplicationContext(),EasyTwo.class);
                startActivity(意向);
        }
    });

}
 

}     * \

解决方案

 新CountDownTimer(3000,100){
         公共无效onFinish(){

          }

        @覆盖
        公共无效onTick(长为arg0){
            // TODO自动生成方法存根

        }
        }。开始();
 

i have a question game that has time limit. how can i code if else= if he answer it correct he will intent to the next level and if he didnt answer it within 10sec he will be intent in another class

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.easyone);
    a1 = (Button) findViewById(R.id.btn_ea1);
    b1 = (Button) findViewById(R.id.btn_eb1);
    c1 = (Button) findViewById(R.id.btn_ec1);

    a1.setOnClickListener(new View.OnClickListener() {

        @Override   
           public void onClick(View v) {
                Toast.makeText(getApplicationContext(),"CORRECT!",
                        Toast.LENGTH_SHORT).show();
                Intent intent = new Intent(getApplicationContext(),EasyTwo.class);
                startActivity(intent);
        }
    });

}

} *\

解决方案

         new CountDownTimer(3000, 100) {
         public void onFinish() {

          }

        @Override
        public void onTick(long arg0) {
            // TODO Auto-generated method stub

        } 
        }.start();

这篇关于如何把倒数计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆