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

前端 未结 4 1759
感动是毒
感动是毒 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

       String text = editText.getText().toString(); 
       if(!text.equals("") && text.matches("^\\d+$")){
           cast to int
        }
    

提交回复
热议问题