安卓的EditText长preSS:ArrayIndexOutOfBoundsException异常:长度= 15;指数= 491 [英] Android EditText on longPress: ArrayIndexOutOfBoundsException: length=15; index=491
问题描述
我有这种奇怪的行为,我无法解释。 我的布局非常简单:一个EditText:
< XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:重力=中心
机器人:方向=垂直
机器人:填充=10dp>
<的EditText
机器人:ID =@ + ID / etPass
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT/>
< / LinearLayout中>
当我尝试长preSS它(粘贴一些文字),我得到了一个imediate强制关闭与此错误:
05-08 16:56:16.838:E / AndroidRuntime(12164):致命异常:主要
05-08 16:56:16.838:E / AndroidRuntime(12164):android.view.InflateException:二进制XML文件中的行#17:错误充气类<未知>
05-08 16:56:16.838:E / AndroidRuntime(12164):在android.view.LayoutInflater.createView(LayoutInflater.java:613)
05-08 16:56:16.838:E / AndroidRuntime(12164):在com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
05-08 16:56:16.838:E / AndroidRuntime(12164):在android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
05-08 16:56:16.838:E / AndroidRuntime(12164):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
05-08 16:56:16.838:E / AndroidRuntime(12164):在android.view.LayoutInflater.inflate(LayoutInflater.java:466)
05-08 16:56:16.838:E / AndroidRuntime(12164):在android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-08 16:56:16.838:E / AndroidRuntime(12164):在android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-08 16:56:16.838:E / AndroidRuntime(12164):在android.widget.Editor $ ActionPopupWindow.initContentView(Editor.java:2995)
。05-08 16:56:16.838:E / AndroidRuntime(12164):在android.widget.Editor $ PinnedPopupWindow< INIT>(Editor.java:2280)
。05-08 16:56:16.838:E / AndroidRuntime(12164):在android.widget.Editor $ ActionPopupWindow< INIT>(Editor.java:2968)
。05-08 16:56:16.838:E / AndroidRuntime(12164):在android.widget.Editor $ ActionPopupWindow< INIT>(Editor.java:2968)
05-08 16:56:16.838:E / AndroidRuntime(12164):在android.widget.Editor $ HandleView.showActionPopupWindow(Editor.java:3189)
05-08 16:56:16.838:E / AndroidRuntime(12164):在android.widget.Editor $ InsertionHandleView.showWithActionPopup(Editor.java:3416)
05-08 16:56:16.838:E / AndroidRuntime(12164):在android.widget.Editor $ InsertionPointCursorController.showWithActionPopup(Editor.java:3652)
05-08 16:56:16.838:E / AndroidRuntime(12164):在android.widget.Editor.performLongClick(Editor.java:870)
05-08 16:56:16.838:E / AndroidRuntime(12164):在android.widget.TextView.performLongClick(TextView.java:7973)
05-08 16:56:16.838:E / AndroidRuntime(12164):在android.view.View $ CheckForLong press.run(View.java:17140)
05-08 16:56:16.838:E / AndroidRuntime(12164):在android.os.Handler.handleCallback(Handler.java:615)
05-08 16:56:16.838:E / AndroidRuntime(12164):在android.os.Handler.dispatchMessage(Handler.java:92)
05-08 16:56:16.838:E / AndroidRuntime(12164):在android.os.Looper.loop(Looper.java:213)
05-08 16:56:16.838:E / AndroidRuntime(12164):在android.app.ActivityThread.main(ActivityThread.java:4786)
05-08 16:56:16.838:E / AndroidRuntime(12164):在java.lang.reflect.Method.invokeNative(本机方法)
05-08 16:56:16.838:E / AndroidRuntime(12164):在java.lang.reflect.Method.invoke(Method.java:511)
05-08 16:56:16.838:E / AndroidRuntime(12164):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:789)
05-08 16:56:16.838:E / AndroidRuntime(12164):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
05-08 16:56:16.838:E / AndroidRuntime(12164):在dalvik.system.NativeStart.main(本机方法)
05-08 16:56:16.838:E / AndroidRuntime(12164):由:java.lang.reflect.InvocationTargetException
05-08 16:56:16.838:E / AndroidRuntime(12164):在java.lang.reflect.Constructor.constructNative(本机方法)
05-08 16:56:16.838:E / AndroidRuntime(12164):在java.lang.reflect.Constructor.newInstance(Constructor.java:417)
05-08 16:56:16.838:E / AndroidRuntime(12164):在android.view.LayoutInflater.createView(LayoutInflater.java:587)
05-08 16:56:16.838:E / AndroidRuntime(12164):25 ...更多
05-08 16:56:16.838:E / AndroidRuntime(12164):java.lang.ArrayIndexOutOfBoundsException:产生的原因长度= 15;指数= 491
05-08 16:56:16.838:E / AndroidRuntime(12164):在android.content.res.StringBlock.get(StringBlock.java:64)
05-08 16:56:16.838:E / AndroidRuntime(12164):在android.content.res.XmlBlock $ Parser.getPooledString(XmlBlock.java:458)
05-08 16:56:16.838:E / AndroidRuntime(12164):在android.content.res.TypedArray.loadStringValueAt(TypedArray.java:720)
05-08 16:56:16.838:E / AndroidRuntime(12164):在android.content.res.TypedArray.getString(TypedArray.java:124)
。05-08 16:56:16.838:E / AndroidRuntime(12164):在android.widget.TextView< INIT>(TextView.java:800)
。05-08 16:56:16.838:E / AndroidRuntime(12164):在android.widget.TextView< INIT>(TextView.java:450)
05-08 16:56:16.838:E / AndroidRuntime(12164):28 ...更多
我真的不知道发生了什么,我会很高兴得到一些帮助!
只是要清楚,我没有在我的相关活动的听众对这个的EditText:
进口android.app.Activity;
进口android.os.Bundle;
公共类了ProActivity延伸活动{
@覆盖
公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_pro);
}
}
答案是相当可怕的......
随着@devconsole在帖子的评论的帮助下,我一看这个主题。
这一行:
<项目名称=机器人:fontFamily中>无衬线光< /项目>
将在崩溃的EditText时长pressing吧。
Android的复制/粘贴弹出是错误的根本原因。
I have this strange behavior I cannot explain. My layout is quite simple: An EditText:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:padding="10dp" >
<EditText
android:id="@+id/etPass"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
When I try to longPress it (to paste some text) I got an imediate Force Close and this error:
05-08 16:56:16.838: E/AndroidRuntime(12164): FATAL EXCEPTION: main
05-08 16:56:16.838: E/AndroidRuntime(12164): android.view.InflateException: Binary XML file line #17: Error inflating class <unknown>
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
05-08 16:56:16.838: E/AndroidRuntime(12164): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor$ActionPopupWindow.initContentView(Editor.java:2995)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor$PinnedPopupWindow.<init>(Editor.java:2280)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:2968)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:2968)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor$HandleView.showActionPopupWindow(Editor.java:3189)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor$InsertionHandleView.showWithActionPopup(Editor.java:3416)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor$InsertionPointCursorController.showWithActionPopup(Editor.java:3652)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor.performLongClick(Editor.java:870)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.TextView.performLongClick(TextView.java:7973)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.View$CheckForLongPress.run(View.java:17140)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.os.Handler.handleCallback(Handler.java:615)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.os.Handler.dispatchMessage(Handler.java:92)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.os.Looper.loop(Looper.java:213)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.app.ActivityThread.main(ActivityThread.java:4786)
05-08 16:56:16.838: E/AndroidRuntime(12164): at java.lang.reflect.Method.invokeNative(Native Method)
05-08 16:56:16.838: E/AndroidRuntime(12164): at java.lang.reflect.Method.invoke(Method.java:511)
05-08 16:56:16.838: E/AndroidRuntime(12164): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
05-08 16:56:16.838: E/AndroidRuntime(12164): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
05-08 16:56:16.838: E/AndroidRuntime(12164): at dalvik.system.NativeStart.main(Native Method)
05-08 16:56:16.838: E/AndroidRuntime(12164): Caused by: java.lang.reflect.InvocationTargetException
05-08 16:56:16.838: E/AndroidRuntime(12164): at java.lang.reflect.Constructor.constructNative(Native Method)
05-08 16:56:16.838: E/AndroidRuntime(12164): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
05-08 16:56:16.838: E/AndroidRuntime(12164): ... 25 more
05-08 16:56:16.838: E/AndroidRuntime(12164): Caused by: java.lang.ArrayIndexOutOfBoundsException: length=15; index=491
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.content.res.StringBlock.get(StringBlock.java:64)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.content.res.XmlBlock$Parser.getPooledString(XmlBlock.java:458)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.content.res.TypedArray.loadStringValueAt(TypedArray.java:720)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.content.res.TypedArray.getString(TypedArray.java:124)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.TextView.<init>(TextView.java:800)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.TextView.<init>(TextView.java:450)
05-08 16:56:16.838: E/AndroidRuntime(12164): ... 28 more
I have really no clue what's happening, and I would be pleased to get some help!
Just to be clear, I have nothing in my Activity related to a listener on this EditText:
import android.app.Activity;
import android.os.Bundle;
public class ProActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_pro);
}
}
The answer is quite scary...
With the help of @devconsole in the comment of the post, I had a look at the theme.
This single line:
<item name="android:fontFamily">sans-serif-light</item>
Will make the EditText crash when long pressing it.
The Android copy/paste popup was the root cause of the error.
这篇关于安卓的EditText长preSS:ArrayIndexOutOfBoundsException异常:长度= 15;指数= 491的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!