android - 如果 Android 中的 EditText.getText() 为空,它会返回什么?

标签 android

我试过 null 和空字符串,还有其他想法吗?

最佳答案

没有其他可能。

getText 实际上永远不会返回 null。它返回内容可能为空的CharSequence

而不是执行 getText().toString().equals("") 或反之亦然,执行 getText().length() == 0 可能会更快

关于android - 如果 Android 中的 EditText.getText() 为空,它会返回什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2785907/

相关文章:

android - onSaveInstanceState 不能保存静态变量?

Android源码编译: failed to build some targets (03:03 (mm:ss))

java - 在 com.unity3d.player 中找不到 UnityPlayerActivity 类

android - 通过 chrome ARC Welder 调试应用程序

android - 项目根项目 "Gradle project not found for Module: "MyApplication"

android - 在 Android 上使用自己的推特身份验证

java - 使用 MediaCodec 进行压缩

android - "dlopen failed: is 32-bit instead of 64-bit"仅在测试中

java.lang.NullPointerException :com. google.android.gms.maps.GoogleMap.moveCamera

android - 回收站 View : how to catch the onClick on an ImageView?