在某些设备中,当我尝试从edittext中选择文本进行复制时会导致
ArithmeticException
我在活动中使用该edittext扩展自 AppCompatActivity
这是例外
E / MessageQueue-JNI:MessageQueue回调中的异常: handleReceiveCallback E / MessageQueue-JNI: java.lang.ArithmeticException:在
处除以零 android.widget.Editor.updateShowAsAction(Editor.java:6034) android.widget.Editor $ SelectionActionModeCallback.onCreateActionMode (Editor.java:3208) com.android.internal.policy.impl.PhoneWindow $ DecorView $ ActionModeCallbackWrapper.onCreateActionMode (PhoneWindow.java:3522) android.support.v7.internal.view.SupportActionModeWrapper $ CallbackWrapper.onCreateActionMode (SupportActionModeWrapper.java:155) android.support.v7.app.AppCompatDelegateImplV7 $ ActionModeCallbackWrapperV7.onCreateActionMode (AppCompatDelegateImplV7.java:1644) android.support.v7.app.AppCompatDelegateImplV7.startSupportActionModeFromWindow (AppCompatDelegateImplV7.java:748) android.support.v7.app.AppCompatDelegateImplV7.startSupportActionMode (AppCompatDelegateImplV7.java:642) android.support.v7.app.AppCompatDelegateImplV14 $ AppCompatWindowCallbackV14.startAsSupportActionMode (AppCompatDelegateImplV14.java:74) android.support.v7.app.AppCompatDelegateImplV14 $ AppCompatWindowCallbackV14.onWindowStartingActionMode (AppCompatDelegateImplV14.java:58) com.android.internal.policy.impl.PhoneWindow $ DecorView.startActionMode (PhoneWindow.java:2981) com.android.internal.policy.impl.PhoneWindow $ DecorView.startActionModeForChild (PhoneWindow.java:2968)android.view.ViewGroup.startActionModeForChild (ViewGroup.java:710)android.view.ViewGroup.startActionModeForChild (ViewGroup.java:710)android.view.ViewGroup.startActionModeForChild (ViewGroup.java:710)android.view.ViewGroup.startActionModeForChild (ViewGroup.java:710)android.view.ViewGroup.startActionModeForChild (ViewGroup.java:710)android.view.ViewGroup.startActionModeForChild (ViewGroup.java:710)android.view.ViewGroup.startActionModeForChild (ViewGroup.java:710)android.view.ViewGroup.startActionModeForChild (ViewGroup.java:710)android.view.ViewGroup.startActionModeForChild (ViewGroup.java:710)android.view.ViewGroup.startActionModeForChild (ViewGroup.java:710)android.view.ViewGroup.startActionModeForChild (ViewGroup.java:710)android.view.ViewGroup.startActionModeForChild (ViewGroup.java:710)android.view.ViewGroup.startActionModeForChild (ViewGroup.java:710)android.view.View.startActionMode (View.java:5292)android.widget.Editor.startSelectionActionMode (Editor.java:1723) android.widget.Editor $ SelectionModifierCursorController.onTouchEvent (Editor.java:5500)android.widget.Editor.onTouchEvent (Editor.java:1211)android.widget.TextView.onTouchEvent (TextView.java:9567)android.view.View.dispatchTouchEvent (View.java:8975)android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2709)android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2371) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2709)android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2371) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2709)android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2371) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2709)android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2371) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2709)android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2371)android.widget.ScrollView.dispatchTouchEvent (ScrollView.java:615) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2709)android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2371) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2709)android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2371) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2709)android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2371) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2709)android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2371) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2709)android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2371) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2709)android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2371) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2709)android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2371) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2709)android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2371) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2709)android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2371) com.android.internal.policy.impl.PhoneWindow $ DecorView.superDispatchTouchEvent (PhoneWindow.java:2568) com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent (PhoneWindow.java:1776)android.app.Activity.dispatchTouchEvent (Activity.java:2866) android.support.v7.internal.view.WindowCallbackWrapper.dispatchTouchEvent (WindowCallbackWrapper.java:60) com.android.internal.policy.impl.PhoneWindow $ DecorView.dispatchTouchEvent (PhoneWindow.java:2529)android.view.View.dispatchPointerEvent (View.java:9180) android.view.ViewRootImpl $ ViewPostImeInputStage.processPointerEvent (ViewRootImpl.java:4734) android.view.ViewRootImpl $ ViewPostImeInputStage.onProcess (ViewRootImpl.java:4572)android.view.ViewRootImpl $ InputStage.deliver (ViewRootImpl.java:4096) android.view.ViewRootImpl $ InputStage.onDeliverToNext (ViewRootImpl.java:4149)android.view.ViewRootImpl $ InputStage.forward (ViewRootImpl.java:4115) android.view.ViewRootImpl $ AsyncInputStage.forward (ViewRootImpl.java:4229)android.view.ViewRootImpl $ InputStage.apply (ViewRootImpl.java:4123) android.view.ViewRootImpl $ AsyncInputStage.apply (ViewRootImpl.java:4286)android.view.ViewRootImpl $ InputStage.deliver (ViewRootImpl.java:4096) android.view.ViewRootImpl $ InputStage.onDeliverToNext (ViewRootImpl.java:4149)android.view.ViewRootImpl $ InputStage.forward (ViewRootImpl.java:4115)android.view.ViewRootImpl $ InputStage.apply (ViewRootImpl.java:4123)android.view.ViewRootImpl $ InputStage.deliver (ViewRootImpl.java:4096)android.view.ViewRootImpl.deliverInputEvent (ViewRootImpl.java:6594) android.view.ViewRootImpl.doProcessInputEvents (ViewRootImpl.java:6484)android.view.ViewRootImpl.enqueueInputEvent (ViewRootImpl.java:6455) android.view.ViewRootImpl $ WindowInputEventReceiver.onInputEvent (ViewRootImpl.java:6684) android.view.InputEventReceiver.dispatchInputEvent (InputEventReceiver.java:185)android.os.MessageQueue.nativePollOnce (MessageQueue.java)android.os.MessageQueue.next (MessageQueue.java:143)android.os.Looper.loop(Looper.java:130) android.app.ActivityThread.main(ActivityThread.java:5944) java.lang.reflect.Method.invoke(Method.java) java.lang.reflect.Method.invoke(Method.java:372) com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:1399)
此方法中的异常原因
android.widget.Editor.updateShowAsAction(Editor.java:6034)
这是我的edittext
的xml代码 <EditText
android:id="@+id/etIdNumber"
android:hint="@string/user_profile_myInfo_add_identification_dialog_et_hint"
android:inputType="number"
style="@style/et_rounded_corner_white_bg"
/>
这是我的风格
<style name="et_rounded_corner_white_bg" parent="horizontal_margin">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">@color/black</item>
<item name="android:background">@drawable/editfield_bg</item>
<item name="android:textColorHint">@color/font_very_light_gray</item>
<item name="android:padding">@dimen/padding_5dp</item>
<item name="android:layout_marginBottom">@dimen/padding_10dp</item>
<item name="android:textCursorDrawable">@null</item>
</style>
答案 0 :(得分:1)
当您双击EditText后,设备在操作栏中设置复制/粘贴操作按钮时,会发生此错误。它将检索actionButtonStyle的minWidth属性。不要将其设置为0dp,而是使用1dp。代码示例:
<item name="android:actionButtonStyle">@style/myTheme.ActionButtonStyle</item>
<style name="myTheme.ActionButtonStyle" parent="@android:style/Widget.Holo.Light.ActionButton">
<item name="android:background">@drawable/actionbutton_bg</item>
<item name="android:textColor">@color/title_foreground</item>
<item name="android:textSize">16sp</item>
<item name="android:textStyle">normal</item>
<item name="android:minWidth">1dp</item>
<item name="android:paddingLeft">12dp</item>
<item name="android:paddingStart">12dp</item>
<item name="android:paddingRight">12dp</item>
<item name="android:paddingEnd">12dp</item>
</style>
答案 1 :(得分:0)
它会完成工作!!
if (symbol != ' ' && symbol != '\n')
从样式中移除此行:
<EditText
android:id="@+id/etIdNumber"
android:hint="@string/user_profile_myInfo_add_identification_dialog_et_hint"
android:inputType="number"
style="@style/et_rounded_corner_white_bg"/>