java.lang.NumberFormatException: Invalid int: “” : Error

前端 未结 5 1971
南笙
南笙 2021-01-21 08:22

I am doing some calculation but unable to parse a string into int or even in float.I searched for solution and i read it somewhere there must be a empty string but i checked my

5条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-21 08:55

    put these lines inside onClick()

    final  String height = e1.getText().toString();
    final int a = Integer.parseInt(height);
    

    You are fetching value of e1 in onCreate(), while you want it when user click on button

    Also need to check whether height is having any value or not, check Stuluske's answer for this

提交回复
热议问题