我是新來的android開發,我試圖開發一個應用程序,其中用戶可以保留一些文本字段爲空, 但是,當用戶沒有在文本字段應用程序崩潰提供任何輸入。 我們如何處理android中的空文本字段如何在Android中保持文本字段爲空?
以下是我對文本字段的代碼。
<EditText
android:layout_width="40dp"
android:layout_height="40dp"
android:inputType="number"
android:ems="10"
android:id="@+id/editText1"
android:layout_weight="1"
android:background="#ffb7ffbf"/>`
java代碼:
TextView t1 = (TextView)findViewById(R.id.editText1);
a1 = Integer.parseInt(t1.getText().toString());
使用LogCat檢查與您的崩潰相關的Java堆棧跟蹤:https://stackoverflow.com/questions/23353173/uncomfort-myapp-has-stopped-how-can-i-solve-this – CommonsWare
即時猜測你做一些與t1.getText(),它拋出一個空指針異常,即時通訊權利? – Akariuz
這不足以查看應用程序崩潰的原因。你的活動還有什麼與文本字段? – BSMP