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.There is some problems with these EditText :
- I have to tap them 2 times in order to have the keyboard to appear
- if I long press one of the EditText the app freeze and crash (only on my phone - Samsung galaxy S, not on the emulator)
It does not happen if the Edittext are NOT in a <include>
ta开发者_如何学编程g ...
regards, Christophe
I have the same problem about long click EditText or TextView crash on Samsung device with Android 4.0 up.
The crash log in here
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
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.
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"
set minWidth to zero, cause samsung system calculate action button position resulted
java.lang.ArithmeticException: divide by zero
Finally set minWidth to not zero, the problem solved.
I wanted to comment on the answer given below (https://stackoverflow.com/a/11966733/1777346) but don't have enough reputation points yet!
We also ran into the same "java.lang.ArithmeticException: divide by zero" exception on Samsung devices (didn't test other devices.. all Samsung). It would occur when long-pressing existing text in an EditText field.
The solution below worked.. we had the following style defined. Changing minWidth to "1" fixed this.
<style name="ActionButtonStyle" parent="@android:style/Widget.Holo.Light.ActionButton">
<item name="android:minWidth">0dp</item>
精彩评论