Edit Text shows exception Invalid Int “”

前端 未结 5 1186
南方客
南方客 2020-12-07 04:50

I have already tried setting the EditText default value to be zero but when it comes to editing and erase as \"\" ( empty space , no more wordings _ in the Edit Text field <

5条回答
  •  无人及你
    2020-12-07 05:17

    Surround the offending lines with a try/catch block.

    try {
        Log.d("Month" , monthlyTest);
        Log.d("freeMonths" , freeMonths);                               
        monthlyFeeforChannel =  Integer.parseInt(monthlyTest);                                      
        MonthlyFee.add(monthlyFeeforChannel);
        FreePeriod.add(freeMonths);
    }
    catch (NumberFormatException nfe) {
        nfe.printStackTrace();
        // Alert the user/log the error, etc.
    }
    

提交回复
热议问题