EditText 在 LG Optimus w/Swype 上发生奇怪的崩溃(适用于模拟器和 Droid)
我有一个可以在模拟器和 Droid 手机上运行的应用程序。在 LG Optimus(顺便说一句,安装了 Swype)上进行测试时,它崩溃并显示以下堆栈跟踪(注意:它位于 EditText 的构造函数中)。
奇怪的是,TextView (981) 中假定的违规行是 getDefualtView() 的方法签名,并且 2.2 源代码中的 EditText 或 TextView 中没有对 GestureDetector 的引用。
我推测(或者冒险猜测这很可能是由于 Swype)并且不确定:
- 如果是 swype,那么我该怎么办 编写我的代码,使其成为 swype 友好的?
- 如果不是 swype, 那会是什么?什么? 令人费解的是,它是在 使用默认样式的构造函数, 属性为 null。
任何帮助表示赞赏。
最诚挚的问候, S-
-- stacktrace snip --
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at android.os.Handler.<init>(Handler.java:121)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at android.view.GestureDetector$GestureHandler.<init>(GestureDetector.java:250)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at android.view.GestureDetector.<init>(GestureDetector.java:370)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at android.view.GestureDetector.<init>(GestureDetector.java:347)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at android.view.GestureDetector.<init>(GestureDetector.java:331)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at android.widget.TextView.<init>(TextView.java:981)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at android.widget.EditText.<init>(EditText.java:55)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at android.widget.EditText.<init>(EditText.java:51)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at android.widget.EditText.<init>(EditText.java:47)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at com.mobiapps.android.gui.EditTextImpl.<init>(EditTextImpl.java:28)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at com.mobiapps.android.gui.TextFieldImpl.makeTextView(TextFieldImpl.java:23)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at com.mobiapps.android.gui.ToolkitImpl.createTextField(ToolkitImpl.java:429)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at com.mobiapps.android.gui.ToolkitImpl.createWidgets(ToolkitImpl.java:492)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at com.mobiapps.android.gui.ToolkitImpl.initializeContainer(ToolkitImpl.java:555)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at com.mobiapps.common.gui.WidgetContainer.initializeImpl(WidgetContainer.java:88)
-- 结束堆栈跟踪 --
Blockquote
I have an app which works in the emulator and on Droid phones. While testing on an LG Optimus (which BTW has Swype installed) it crashes with the following stack trace (NOTE: it is in the constructor of EditText).
What is weird is that supposed offending line in TextView (981) is the method signature for getDefualtView(
) and there are no references to GestureDetector in EditText or TextView in 2.2 source code.
I'm presuming (or hazarding a guess that it is most likely due to Swype) and am not sure of:
- if it is swype, then how do i
write my code so that it is swype
friendly? - if it is not swype,
then what could it be? Whats
baffling is that it is in the
constructor using default styles,
and null for attributes.
any help is appreciated.
Kindest regards,
S-
-- stacktrace snip --
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at android.os.Handler.<init>(Handler.java:121)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at android.view.GestureDetector$GestureHandler.<init>(GestureDetector.java:250)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at android.view.GestureDetector.<init>(GestureDetector.java:370)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at android.view.GestureDetector.<init>(GestureDetector.java:347)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at android.view.GestureDetector.<init>(GestureDetector.java:331)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at android.widget.TextView.<init>(TextView.java:981)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at android.widget.EditText.<init>(EditText.java:55)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at android.widget.EditText.<init>(EditText.java:51)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at android.widget.EditText.<init>(EditText.java:47)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at com.mobiapps.android.gui.EditTextImpl.<init>(EditTextImpl.java:28)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at com.mobiapps.android.gui.TextFieldImpl.makeTextView(TextFieldImpl.java:23)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at com.mobiapps.android.gui.ToolkitImpl.createTextField(ToolkitImpl.java:429)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at com.mobiapps.android.gui.ToolkitImpl.createWidgets(ToolkitImpl.java:492)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at com.mobiapps.android.gui.ToolkitImpl.initializeContainer(ToolkitImpl.java:555)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912): at com.mobiapps.common.gui.WidgetContainer.initializeImpl(WidgetContainer.java:88)
-- end stack trace --
Blockquote
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我查看了源代码,似乎在 UI 线程中调用
Looper.prepare()
将修复此异常。但这很奇怪。您使用多线程吗?I looked into sources and it seems that invoking
Looper.prepare()
in the UI thread will fix this exeption. But it's very strange. Are you using multiple threads?