这是一个非常奇怪的错误,发生在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"/>