久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

編輯文本顯示異常 Invalid Int “";

Edit Text shows exception Invalid Int quot;quot;(編輯文本顯示異常 Invalid Int “;)
本文介紹了編輯文本顯示異常 Invalid Int “";的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我已經嘗試將 EditText 默認值設置為零,但是當涉及到編輯和擦除為"(空白,編輯文本字段中沒有更多的措辭 _

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

按下提交按鈕時顯示異常 Invalid Int "".你能告訴我如何解決這個異常嗎?

It shows exception Invalid Int "" when pressing submitt button . Could you please tell me how to resolve this exception ?

下面是我的代碼

    for (int j = 0; j < selectedChannels; j++) {

        lconper = (Spinner) findViewById (j+120);
        int monthlyFeeforChannel = 0;       
        contractPeriodSelected.add((String) lconper.getSelectedItem());

        String monthlyTest = txtMonthlyFee[j].getText().toString().trim();
        String freeMonths = txtFreePeriod[j].getText().toString().trim();

        if(monthlyTest.trim()==null || monthlyTest.trim()==""){
            new AlertDialog.Builder(this)
            .setTitle("Warning")
            .setMessage(
                    "You must fill in Monthly Fees for subscribed channels!")
                    .setNeutralButton("OK",
                            new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog,
                                int id) {
                            // if this button is clicked, close
                            // current activity
                            dialog.cancel();
                        }});
            break;
        }
        else
        {
            Log.d("Month" , monthlyTest);
            Log.d("freeMonths" , freeMonths);                               
            monthlyFeeforChannel =  Integer.parseInt(monthlyTest);                                      
            monthlyFee.add(monthlyFeeforChannel);
            FreePeriod.add(freeMonths);     
        }   
    }

Logcat

    06-20 13:52:03.711: E/AndroidRuntime(17713): FATAL EXCEPTION: main
06-20 13:52:03.711: E/AndroidRuntime(17713): java.lang.IllegalStateException: Could not execute method of the activity
06-20 13:52:03.711: E/AndroidRuntime(17713):    at android.view.View$1.onClick(View.java:3130)
06-20 13:52:03.711: E/AndroidRuntime(17713):    at android.view.View.performClick(View.java:3652)
06-20 13:52:03.711: E/AndroidRuntime(17713):    at android.view.View$PerformClick.run(View.java:14354)
06-20 13:52:03.711: E/AndroidRuntime(17713):    at android.os.Handler.handleCallback(Handler.java:605)
06-20 13:52:03.711: E/AndroidRuntime(17713):    at android.os.Handler.dispatchMessage(Handler.java:92)
06-20 13:52:03.711: E/AndroidRuntime(17713):    at android.os.Looper.loop(Looper.java:137)
06-20 13:52:03.711: E/AndroidRuntime(17713):    at android.app.ActivityThread.main(ActivityThread.java:4519)
06-20 13:52:03.711: E/AndroidRuntime(17713):    at java.lang.reflect.Method.invokeNative(Native Method)
06-20 13:52:03.711: E/AndroidRuntime(17713):    at java.lang.reflect.Method.invoke(Method.java:511)
06-20 13:52:03.711: E/AndroidRuntime(17713):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
06-20 13:52:03.711: E/AndroidRuntime(17713):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:561)
06-20 13:52:03.711: E/AndroidRuntime(17713):    at dalvik.system.NativeStart.main(Native Method)
06-20 13:52:03.711: E/AndroidRuntime(17713): Caused by: java.lang.reflect.InvocationTargetException
06-20 13:52:03.711: E/AndroidRuntime(17713):    at java.lang.reflect.Method.invokeNative(Native Method)
06-20 13:52:03.711: E/AndroidRuntime(17713):    at java.lang.reflect.Method.invoke(Method.java:511)
06-20 13:52:03.711: E/AndroidRuntime(17713):    at android.view.View$1.onClick(View.java:3125)
06-20 13:52:03.711: E/AndroidRuntime(17713):    ... 11 more
06-20 13:52:03.711: E/AndroidRuntime(17713): Caused by: java.lang.NumberFormatException: Invalid int: ""
06-20 13:52:03.711: E/AndroidRuntime(17713):    at java.lang.Integer.invalidInt(Integer.java:138)
06-20 13:52:03.711: E/AndroidRuntime(17713):    at java.lang.Integer.parseInt(Integer.java:359)
06-20 13:52:03.711: E/AndroidRuntime(17713):    at java.lang.Integer.parseInt(Integer.java:332)
06-20 13:52:03.711: E/AndroidRuntime(17713):    at com.test.Eystem1.Confirm.submitOrder(Confirm.java:415)
06-20 13:52:03.711: E/AndroidRuntime(17713):    ... 14 more

推薦答案

在您使用的 aboue 代碼中,例如將 String 轉換為 Integer,在這種情況下,您不會將 ""(Empty String) 轉換為 Integer

In the aboue code you have used like converting String to Integer in that case you will not convert ""(Empty String) to Integer

Integer.parseInt(monthlyTest);  // Here monthyTest value is ""

轉換前請確保字符串不為空.

Please make sure the string is not empty befor conversion.

檢查String的長度是否應該大于0.

Check the length of the String is should be greater than 0.

if(monthlyTest.length()>0)

謝謝.....

這篇關于編輯文本顯示異常 Invalid Int “";的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

EditText: Disable Paste/Replace menu pop-up on Text Selection Handler click event(EditText:禁用文本選擇處理程序單擊事件上的粘貼/替換菜單彈出)
Multiline EditText with Done SoftInput Action Label on 2.3(2.3 上帶有完成 SoftInput 操作標簽的多行 EditText)
How to detect the swipe left or Right in Android?(如何在 Android 中檢測向左或向右滑動?)
Prevent dialog dismissal on screen rotation in Android(防止在Android中的屏幕旋轉對話框解除)
How do I handle ImeOptions#39; done button click?(如何處理 ImeOptions 的完成按鈕點擊?)
How do you set EditText to only accept numeric values in Android?(您如何將 EditText 設置為僅接受 Android 中的數值?)
主站蜘蛛池模板: 亚洲中午字幕 | 久久久片 | 久久亚洲一区 | 国产精品一区二区在线播放 | 免费在线观看av网站 | 欧美国产亚洲一区二区 | 精品三级在线观看 | 亚洲精品久久久久中文字幕二区 | 天堂一区 | 亚洲午夜av久久乱码 | 男女视频91| 亚洲精品国产电影 | 亚洲视频精品在线 | 国产福利资源在线 | 久久久久久久久久性 | 日本黄色一级视频 | 久久最新精品视频 | 一二三区视频 | 久久久精品亚洲 | 欧美日韩国产三级 | 欧美一区二区三区四区视频 | 亚洲国产区 | 国产一区二区三区四区五区3d | 天堂在线网 | 久久久成 | 国产精品成人一区二区 | 国产精品福利网站 | 国产精品欧美日韩 | 一区二区三区在线看 | 欧美激情综合五月色丁香小说 | 久久久精品在线 | 国产精品福利网站 | 一区二区三区国产精品 | 欧美亚洲国产日韩 | 久久免费国产视频 | 天堂资源最新在线 | 久久这里只有精品首页 | 一区二区三区四区免费观看 | 日本黄色短片 | 亚洲欧美日韩精品 | 国产精品久久久久久久久大全 |