【发布时间】:2023-03-14 20:35:01
【问题描述】:
我无法在 Androis Studio 中获取 EditText 的 int 值
我用Int FirstValue = Integer.parseInt(FirstInput.getText().toString());
但是当我使用它时,我的应用程序将在 Evulator 中停止!
此问题适用于我所有的 Android Studio 应用程序
【问题讨论】:
-
它是
int firstValue = Integer.parseInt(FirstInput.getText().toString());。在将字符串解析为 int 之前,还要确保 FirstInput 不为空。 -
我怎么知道 firstInput 是否为空?
-
if (FirstInput != null)