這是我再次...我想問如何使我的「按鈕」(calculateButton)不起作用,如果用戶不會輸入他們的體重&高度...或用戶不輸入自己的體重或他們的身高...希望你可以幫我...感謝..在BMI計算器中計算按鈕
這裏是我的calculateButton代碼:
public void calculateClickHandler(View view) {
if (view.getId() == R.id.calculateButton) {
}
EditText weightText = (EditText) findViewById(R.id.weightT);
EditText heightText = (EditText)findViewById(R.id.heightT);
TextView resultText = (TextView)findViewById(R.id.resultLabel);
TextView categoryText = (TextView)findViewById(R.id.categoryLabel);
rGroup = (RadioGroup)findViewById(R.id.rGroup);
int weight = (int) Float.parseFloat(weightText.getText().toString());
int height = (int) Float.parseFloat(heightText.getText().toString());
int bmiValue = calculateBMI(weight, height);
String bmiInterpretation = interpretBMI(bmiValue);
resultText.setText("Your BMI is:" + " " + bmiValue + " " + "and you're");
categoryText.setText(bmiInterpretation + ".");}
檢查出來的[文件](http://docs.oracle.com/javase/tutorial/java /nutsandbolts/if.html)。 – 323go