2013-07-29 40 views
-1

我有一個問題遊戲,有時間限制。我怎樣才能代碼,如果其他=如果他回答是正確的,他將意圖到一個新的水平,如果他沒有內10秒,他會故意在另一類如何把倒數計時器

@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); 
     } 
    }); 

} 

} * \

+0

http://stackoverflow.com/questions/17839419/android-thread-for-a-timer/17839725#17839725。檢查這可能有所幫助。 – Raghunandan

回答

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

      } 

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

     } 
     }.start(); 
回答吧
+0

@Tarsem我並不是說你ü刪除你的答案 – KOTIOS

+0

我怎麼能意圖如果他不在10秒內回答它? – user2582715