这是我再次...我想问如何使我的“按钮”(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