Eclipse裡的JAVA程式碼不知錯誤哪裡

以下是程式碼 package workshop.bmi; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class MainActivity extends Activity { ... show more 以下是程式碼

package workshop.bmi;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity {
private EditText textheight;
private EditText textweight;
private TextView comment;
private Button btnok;

}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
getViews();
setListeners();
}
private void setListeners() {
// TODO Auto-generated method stub
btnok.setOnClickListener(calcBMI);
}

private void getViews() {
// TODO Auto-generated method stub
textheight = (EditText)findViewById(R.id.editHeight);
textweight = (EditText)findViewById(R.id.editWeight);
comment = (TextView)findViewById(R.id.textResult);
btnok = (Button)findViewById(R.id.btnDo);
}

private OnClickListener calcBMI = new OnClickListener(){
@Override
public void onClick(View arg0) {
double stdweight, height, weight, BMI;
DecimalFormat nf = new DecimalFormat("0.0");
height = Double.parseDouble(textheight.getText()....
weight = Double.parseDouble(textweight.getText()....
BMI = weight * 100 * 100 / (height * height);
RadioButton r = null;
r = (RadioButton)findViewById(R.id.radioMan)...
if (r.isChecked()==true)
stdweight = (height-80)* 0.7;
else
stdweight = (height-70)* 0.6;
//Give health comment
comment.setText("你的BMI 值是:" + nf.format(BMI)+ "\n" + "理想體重值為:"+ nf.format(stdweight));
}
}
Update: public class MainActivity extends Activity {
private EditText textheight;
private EditText textweight;
private TextView comment;
private Button btnok;

} ←這個括號出現了"Syntax error on token "}", delete this token"的錯誤,但看不懂
Update 2: 程式碼最後的括號出現了"Syntax error, insert "}" to complete ClassBody"的錯誤,但也看不懂
Update 3: 希望有高人指點,讓正確的程式碼完成
Update 4: 把上面那個括號拿掉,留下面那個再試一次看看?

拿掉之後就只剩下最後一個括號出現了"Syntax error, insert "}" to complete ClassBody"的錯誤
2 answers 2