EditTexts上的左箭头崩溃了应用程序

时间:2012-03-07 17:15:23

标签: android android-edittext

在我的一个活动中,我有几个EditTexts。如果您在模拟器上运行我的应用程序,选择其中一个EditTexts并按硬件键盘上的左箭头键,应用程序将崩溃。

我不确定为什么。我所有其他活动上的所有EditTexts都不会导致此问题。据我所知,我对这个屏幕上的EditTexts没有做任何奇怪的事情。我不会覆盖像onKey这样的处理程序。实际上,除非用户离开屏幕,否则我不会对它们执行任何操作,然后我只需抓取文本。

有什么想法吗?

以下是错误输出:

03-07 11:08:09.781: E/AndroidRuntime(388): Uncaught handler: thread main exiting due to uncaught exception
03-07 11:08:09.811: E/AndroidRuntime(388): java.lang.IndexOutOfBoundsException: charAt: -2 < 0
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.text.SpannableStringBuilder.charAt(SpannableStringBuilder.java:110)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.text.TextUtils.getCapsMode(TextUtils.java:1573)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.inputmethod.BaseInputConnection.getCursorCapsMode(BaseInputConnection.java:273)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.widget.TextView.onCreateInputConnection(TextView.java:4482)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.inputmethod.InputMethodManager.startInputInner(InputMethodManager.java:942)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.inputmethod.InputMethodManager.checkFocus(InputMethodManager.java:1114)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.inputmethod.InputMethodManager.isActive(InputMethodManager.java:539)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.widget.TextView.onDraw(TextView.java:4011)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.View.draw(View.java:6535)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.View.draw(View.java:6538)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.View.draw(View.java:6538)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.View.draw(View.java:6641)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.widget.FrameLayout.draw(FrameLayout.java:352)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.View.draw(View.java:6538)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.View.draw(View.java:6538)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.View.draw(View.java:6538)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.widget.FrameLayout.draw(FrameLayout.java:352)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.View.draw(View.java:6538)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.widget.FrameLayout.draw(FrameLayout.java:352)
03-07 11:08:09.811: E/AndroidRuntime(388):  at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1830)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.ViewRoot.draw(ViewRoot.java:1349)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.ViewRoot.performTraversals(ViewRoot.java:1114)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1633)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.os.Looper.loop(Looper.java:123)
03-07 11:08:09.811: E/AndroidRuntime(388):  at android.app.ActivityThread.main(ActivityThread.java:4363)
03-07 11:08:09.811: E/AndroidRuntime(388):  at java.lang.reflect.Method.invokeNative(Native Method)
03-07 11:08:09.811: E/AndroidRuntime(388):  at java.lang.reflect.Method.invoke(Method.java:521)
03-07 11:08:09.811: E/AndroidRuntime(388):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
03-07 11:08:09.811: E/AndroidRuntime(388):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
03-07 11:08:09.811: E/AndroidRuntime(388):  at dalvik.system.NativeStart.main(Native Method)

同样,我没有遍历文本或处理索引的代码。我没有覆盖任何处理程序。我只是在Activity启动时调用findViewById,并在Activity结束时从EditText中获取文本。

1 个答案:

答案 0 :(得分:1)

已知模拟器上的错误。这是一个link to issue