这是一个非常奇怪的错误,发生在 Android 5.0.1 的 Galaxy Grand Prime 上。
如果我长按任何 TextInputEditText 或 EditText,应用程序将崩溃并显示以下日志:
FATAL EXCEPTION: main
Process: com.x.x, PID: 22222
android.view.InflateException: Binary XML file line #17: Error inflating class TextView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.widget.Editor$ActionPopupWindow.initContentView(Editor.java:3423)
at android.widget.Editor$PinnedPopupWindow.<init>(Editor.java:2595)
at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:3380)
at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:3380)
at android.widget.Editor$HandleView.showActionPopupWindow(Editor.java:4430)
at android.widget.Editor$InsertionHandleView.showWithActionPopup(Editor.java:4791)
at android.widget.Editor$InsertionPointCursorController.showWithActionPopup(Editor.java:5230)
at android.widget.Editor.performLongClick(Editor.java:978)
at android.widget.TextView.performLongClick(TextView.java:9273)
at android.view.View$CheckForLongPress.run(View.java:20253)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5910)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=15; index=386
at android.content.res.StringBlock.get(StringBlock.java:65)
at android.content.res.XmlBlock$Parser.getPooledString(XmlBlock.java:482)
at android.content.res.TypedArray.loadStringValueAt(TypedArray.java:1003)
at android.content.res.TypedArray.getString(TypedArray.java:177)
at android.widget.TextView.<init>(TextView.java:1087)
at android.widget.TextView.<init>(TextView.java:685)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:62)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:58)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103)
at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1029)
at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1087)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:47)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:725)
at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.widget.Editor$ActionPopupWindow.initContentView(Editor.java:3423)
at android.widget.Editor$PinnedPopupWindow.<init>(Editor.java:2595)
at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:3380)
at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:3380)
at android.widget.Editor$HandleView.showActionPopupWindow(Editor.java:4430)
at android.widget.Editor$InsertionHandleView.showWithActionPopup(Editor.java:4791)
at android.widget.Editor$InsertionPointCursorController.showWithActionPopup(Editor.java:5230)
at android.widget.Editor.performLongClick(Editor.java:978)
at android.widget.TextView.performLongClick(TextView.java:9273)
at android.view.View$CheckForLongPress.run(View.java:20253)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5910)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
这发生在各种活动和多个应用程序中。到目前为止,我不知道该怎么做。我最初认为用普通的旧 EditText 替换 TextInputEditText 可以解决问题,但事实并非如此。
相关的 XML:
<android.support.design.widget.TextInputEditText
android:id="@+id/address"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:hint="@string/address"
android:inputType="textPostalAddress"/>