InflateException与TextInputLayout和AlertDialog [英] InflateException with TextInputLayout and AlertDialog
本文介绍了InflateException与TextInputLayout和AlertDialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用最新的 TextInputLayout 在我的 DialogFragment
I am trying to use the newest TextInputLayout in my DialogFragment.
下面是我的code:
<android.support.design.widget.TextInputLayout
android:id="@+id/testingInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/testingEditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/testText"
android:inputType="textEmailAddress" />
</android.support.design.widget.TextInputLayout>
一些背景资料:
- 的启动DialogFragment活动派生自 AppCompatActivity
- 的DialogFragment派生自 Android.Support.V4.App.DialogFragment
- 我通过建立在 Android.Support.V7.App.AlertDialog.Builder 的DialogFragment
- 的DialogFragment通过的 SupportFragmentManager 启动
- 我使用的是最新的支持设计库
- The activity that launches the DialogFragment derives from AppCompatActivity
- The DialogFragment derives from Android.Support.V4.App.DialogFragment
- I build the DialogFragment via the Android.Support.V7.App.AlertDialog.Builder
- The DialogFragment is launched via a SupportFragmentManager
- I am using the latest Support Design Library
下面的错误(我使用Xamarin,因此 MonoDroid的的)
Here's the error (I'm using Xamarin, hence the MonoDroid)
[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] Android.Views.InflateException: Exception of type 'Android.Views.InflateException' was thrown.
[MonoDroid] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <IL 0x00011, 0x00078>
[MonoDroid] at Android.Runtime.JNIEnv.CallObjectMethod (intptr,intptr,Android.Runtime.JValue*) [0x00064] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:195
[MonoDroid] at Android.Views.LayoutInflater.Inflate (int,Android.Views.ViewGroup) [0x0006d] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.Views.LayoutInflater.cs:646
[MonoDroid] at HelloLittleApp.MyOwnDialog.OnCreateDialog (Android.OS.Bundle) [0x00027] in e:\Progetti\HelloLittleApp-Android\Dialogs\MyOwnDialog.cs:22
[MonoDroid] at Android.Support.V4.App.DialogFragment.n_OnCreateDialog_Landroid_os_Bundle_ (intptr,intptr,intptr) <IL 0x00013, 0x000f7>
[MonoDroid] at (wrapper dynamic-method) object.e260d9fd-b921-4418-a47a-496934404e0e (intptr,intptr,intptr) <IL 0x00017, 0x0004b>
[MonoDroid] --- End of managed exception stack trace ---
[MonoDroid] android.view.InflateException: Binary XML file line #1: Error inflating class android.support.design.widget.TextInputLayout
[MonoDroid] at android.view.LayoutInflater.createView(LayoutInflater.java:633)
[MonoDroid] at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
[MonoDroid] at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
[MonoDroid] at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
[MonoDroid] at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
[MonoDroid] at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
[MonoDroid] at md5a2b8d0e6e3890b714223a2b1204f749c.MyOwnDialog.n_onCreateDialog(Native Method)
[MonoDroid] at md5a2b8d0e6e3890b714223a2b1204f749c.MyOwnDialog.onCreateDialog(MyOwnDialog.java:29)
[MonoDroid] at android.support.v4.app.DialogFragment.getLayoutInflater(DialogFragment.java:308)
[MonoDroid] at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:955)
[MonoDroid] at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
[MonoDroid] at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740)
[MonoDroid] at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
[MonoDroid] at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:458)
[MonoDroid] at android.os.Handler.handleCallback(Handler.java:739)
[MonoDroid] at android.os.Handler.dispatchMessage(Handler.java:95)
[MonoDroid] at android.os.Looper.loop(Looper.java:135)
[MonoDroid] at android.app.ActivityThread.main(ActivityThread.java:5254)
[MonoDroid] at java.lang.reflect.Method.invoke(Native Method)
[MonoDroid] at java.lang.reflect.Method.invoke(Method.java:372)
[MonoDroid] at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
[MonoDroid] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
[MonoDroid] Caused by: java.lang.reflect.InvocationTargetException
[MonoDroid] at java.lang.reflect.Constructor.newInstance(Native Method)
[MonoDroid] at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
[MonoDroid] at android.view.LayoutInflater.createView(LayoutInflater.java:607)
[MonoDroid] ... 21 more
[MonoDroid] Caused by: java.lang.RuntimeException: Failed to resolve attribute at index 18
[MonoDroid] at android.content.res.TypedArray.getColor(TypedArray.java:401)
[MonoDroid] at android.support.design.widget.CollapsingTextHelper.setCollapsedTextAppearance(CollapsingTextHelper.java:166)
[MonoDroid] at android.support.design.widget.TextInputLayout.<init>(TextInputLayout.java:106)
[MonoDroid] ... 24 more
[AndroidRuntime] Shutting down VM
任何提示是AP preciated。
Any tip is appreciated.
推荐答案
我有类似的错误:
android.view.InflateException: Binary XML file line #1: Error inflating class android.support.design.widget.TextInputLayout
试图重现一个新的项目,我发现,我的问题是应用程序的主题!尝试设置的android:在Android清单这样的
字段:应用
标记主题
Trying to reproduce it for a new project I found that the problem for me was in App Theme! Try to set android:theme
field in application
tag of Android Manifest like this:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat">
这篇关于InflateException与TextInputLayout和AlertDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文