我是Android的新人,我忘记了很多Java程序.这里我遇到了一个问题,我今天在Eclipse中执行了该程序.
public void cvOnClick (View cvView) {
EditText KilogramsInput = (EditText) findViewById(R.id.Kilograms);
EditText HeightInput = (EditText) findViewById(R.id.Height);
TextView BmiOutput = (TextView) findViewById(R.id.Bmi);
DecimalFormat BmiFormat = new DecimalFormat(".#####");
Double Heightdouble = Math.pow(Integer.parseInt(HeightInput.getText().toString()), 2);
String outcome = BmiFormat.format(Integer.parseInt(KilogramsInput.getText().toString())/Heightdouble);
BmiOutput.setText(outcome);
}
Run Code Online (Sandbox Code Playgroud)
作为这个程序的最初目的,应该是正方形的高度数.在Eclipse中执行没有错误.但是当我把数据(十进制)放在AVD中时,它显示:the application has stopped unexpectedly.
请告诉我此刻我该怎么办?
谢谢你的帮助!布拉德
你正在使用Integer.parseInt()它,但当你输入double而不是一个时,它会感到困惑int.使用Double.parseDouble()而不是Integer.parseInt()它应该工作.
| 归档时间: |
|
| 查看次数: |
3588 次 |
| 最近记录: |