2017-09-09 59 views
0

试图EDITTEXT复制文本时,我得到这个错误:在EditText上(机器人)用拷贝的问题

Exception java.lang.NumberFormatException: Invalid int: "res/drawable/edit_text_material.xml" 
java.lang.Integer.invalidInt (Integer.java:138) 
java.lang.Integer.parse (Integer.java:410) 
java.lang.Integer.parseInt (Integer.java:367) 
com.android.internal.util.XmlUtils.convertValueToInt (XmlUtils.java:133) 
android.content.res.TypedArray.getInt (TypedArray.java:357) 
android.view.animation.Animation.<init> (Animation.java:248) 
android.view.animation.AnimationSet.<init> (AnimationSet.java:81) 
android.view.animation.AnimationUtils.createAnimationFromXml (AnimationUtils.java:117) 
android.view.animation.AnimationUtils.createAnimationFromXml (AnimationUtils.java:95) 
android.view.animation.AnimationUtils.loadAnimation (AnimationUtils.java:76) 
android.widget.Editor$SelectionPopupWindow.createAnimations (Editor.java:4086) 
android.widget.Editor$ActionPinnedPopupWindow.<init> (Editor.java:2543) 
android.widget.Editor$ActionPopupWindow.<init> (Editor.java:3577) 
android.widget.Editor$SelectionPopupWindow.<init> (Editor.java:4074) 
android.widget.Editor$SelectionHandleView.getActionPopupWindow (Editor.java:5337) 
android.widget.Editor$SelectionModifierCursorController.show (Editor.java:5305) 
android.widget.Editor.startSelectionActionMode (Editor.java:1715) 
android.widget.Editor.performLongClick (Editor.java:1020) 

android.app.ActivityThread.main (ActivityThread.java:5438) 
java.lang.reflect.Method.invoke (Method.java) 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:738) 
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:628) 

这是我的布局:

 <android.support.design.widget.TextInputLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="10dp" 
       android:textColorHint="#565d66"> 

       <EditText 
        android:id="@+id/userEditText" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:hint="@string/registration.hint.user" 
        android:textColor="#565d66" 
        android:theme="@style/Custom.EditText" /> 

      </android.support.design.widget.TextInputLayout> 



// this is the theme i'm using in editText: 

     <style name="Custom.EditText" parent="Base.Widget.AppCompat.EditText"> 
     <item name="colorControlNormal">#565d66</item> 
     <item name="colorControlHighlight">@color/colorPrimary</item> 
     <item name="colorControlActivated">@color/colorPrimary</item> 
    </style> 

Android版本:6.0。 1,device:redmi note 4

+2

能否请您分享您的Java代码。 –

+0

你在哪里使用'edit_text_material'主题? – mrid

+0

异常是明确的:尝试解析路径为数字 –

回答

1

嗯,我也遇到这个问题,我通过删除父类型来解决它。

<style name="Custom.EditText"> 
    <item name="colorControlNormal">#565d66</item> 
    <item name="colorControlHighlight">@color/colorPrimary</item> 
    <item name="colorControlActivated">@color/colorPrimary</item> 
</style> 

我认为错误的原因是每个智能手机供应商都制作自定义用户界面,我们需要使用edittext的默认样式。

只要尝试制作没有样式的其他edittext并尝试复制文本。将其与具有自定义样式的人比较,上下文菜单会很奇怪。

PS:对不起,我的英文不好

0

您添加颜色资源。

<color name="customEditText">#565d66</color> 

并修改您的样式代码。

<style name="Custom.EditText" parent="Base.Widget.AppCompat.EditText"> 
    <item name="colorControlNormal">@color/customEditText</item> 
    <item name="colorControlHighlight">@color/colorPrimary</item> 
    <item name="colorControlActivated">@color/colorPrimary</item> 
</style> 

你试试这个