我收到了我无法弄清楚的括号错误。
按下按钮后,代码应该有一个随机数,然后我应该有一个计数器,在它下面计数。我最终的目标是有一个获胜条件,检查数字是否相同并且你获胜。但只需要帮助使这些括号对齐即可。在 Eclipse for android 中执行此操作,任何帮助都会很棒,谢谢!
package com.viralgamez.gastime;
import java.util.Random;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class NewGame<Stopwatch> extends Activity {
private TextView displayRandInt;
private Button updateRandInt;
final int MSG_START_TIMER = 0;
final int MSG_STOP_TIMER = 1;
final int MSG_UPDATE_TIMER = 2;
private static final Random rand = new Random();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.newgame);
/* Setup your Activity */
// Find the views (their id's should be specified in the XML layout file)
displayRandInt = (TextView) findViewById(R.id.displayRandInt);
updateRandInt = (Button) findViewById(R.id.updateRandInt);
// Give the Button an onClickListener
updateRandInt.setOnClickListener(new android.view.View.OnClickListener() {
public void onClick(View v) {
int randInt = rand.nextInt(100)+1;
displayRandInt.setText(String.valueOf(randInt));
}
public void onClick2(View v) {
if(status == false)
{
btnStart.setText("Stop");
status = true;
new Thread(new Runnable()
{ run(){
for(int i=0; i < 500; i++)
{
runOnUiThread(new Runnable()
{
@Override
public void run()
{
txtCounter.setText(String.valueOf(i));
}
});
Thread.sleep(1000);
}}
}).start();
}
else if (status == true)
{
btnStart.setText("Start");
status = false;
initCouner();
});