java.lang.NumberFormatException: Invalid int: “” in android

前端 未结 4 1752
感动是毒
感动是毒 2020-11-28 15:58

I already know what is causing this error, I just do not know how to handle the case when a user doesn\'t enter anything into the dialogue box, then hit the button which par

4条回答
  •  南方客
    南方客 (楼主)
    2020-11-28 16:33

    Some code would help with the syntax but basically

     if ("".equals(text)  // where text is the text that you get from an EditText or wherever you get it
     {    // give message to enter valid text;    }
    

    Also, you can surround with a try/catch and catch a numberFormatException then print an appropriate message

提交回复
热议问题