< include>中带有EditText的奇怪行为标签 [英] strange behavior with EditText inside <include> tag

查看:33
本文介绍了< include>中带有EditText的奇怪行为标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含"include"组件的视图(请参阅

I have a view which include another one with the "include" component (see http://android-developers.blogspot.com/2009/02/android-layout-tricks-2-reusing-layouts.html)
There is some EditText inside the included view.

这些EditText存在一些问题:

There is some problems with these EditText :

  • 我必须点按两次以使键盘出现
  • 如果我长按EditText之一,则应用程序冻结并崩溃(仅在我的手机上-Samsung galaxy S,而不在模拟器上)

如果Edittext不在<include>标记中,则不会发生...
您对这个问题有什么想法吗?

It does not happen if the Edittext are NOT in a <include> tag ...
Do you have any ideas on this problem ??

致谢, 克里斯托夫(Christophe)

regards, Christophe

推荐答案

在Android 4.0或更高版本的三星设备上,如果长时间单击EditText或TextView崩溃,我也会遇到相同的问题.

I have the same problem about long click EditText or TextView crash on Samsung device with Android 4.0 up.

崩溃日志在这里

java.lang.ArithmeticException: divide by zero
at android.widget.TextView$SelectionActionModeCallback.onCreateActionMode(TextView.java:10647)
at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionMode(PhoneWindow.java:2382)
at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionModeForChild(PhoneWindow.java:2322)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:571)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:571)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:571)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:571)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:571)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:571)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:571)
at android.view.View.startActionMode(View.java:3687)
at android.widget.TextView.startSelectionActionMode(TextView.java:10451)
at android.widget.TextView.performLongClick(TextView.java:9570)
at android.view.View$CheckForLongPress.run(View.java:14241)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4507)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)
@Dumpstate > dumpstate -k -t -n -z -d -o /data/log/dumpstate_app_error

这是因为当您长时间单击文本时,三星系统将选择要突出显示的文本 并使用onCreateActionMode()来显示剪切,复制,粘贴等按钮.

It's because when you long click on text, samsung system will select text to highlight and use onCreateActionMode() to show cut, copy, paste etc button.

如果您使用的是Android 4.0及更高版本, 它将显示在ActionBar上,并在您应用的style.xml中使用ActionBar主题样式. 然后我找到了

If you are in Android 4.0 up, it will show on ActionBar and use the ActionBar theme style in your app's style.xml. And I found my

"@android:style/Widget.Holo.ActionButton"

将minWidth设置为零, 导致三星系统计算操作按钮位置结果

set minWidth to zero, cause samsung system calculate action button position resulted

java.lang.ArithmeticException: divide by zero

最后将minWidth设置为不为零,问题就解决了.

Finally set minWidth to not zero, the problem solved.

这篇关于&lt; include&gt;中带有EditText的奇怪行为标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆