InflateException with TextInputLayout and AlertDialog
This happened to me as well, and I came up with a solution inspired by AHTOH's. It requires simply changing the Theme of the TextInputLayout:
<android.support.design.widget.TextInputLayout
android:id="@+id/testingInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/Theme.AppCompat">
<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>
You will need to add the appCompat library if you have not already:
compile 'com.android.support:appcompat-v7:23.0.1'
I had similar error:
android.view.InflateException: Binary XML file line #1: Error inflating class android.support.design.widget.TextInputLayout
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">
- extend your activity from AppCompatActivity
- extend your (dialog)fragment from android.support.v4.app.Fragment.
- use latest version of design library.
Instead of using EditText, use android.support.v7.widget.AppCompatEditText. For example:
<android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" app:errorEnabled="true"> <android.support.v7.widget.AppCompatEditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="First Name" android:inputType="textPersonName" android:singleLine="true" /> </android.support.design.widget.TextInputLayout>
Also, if you didn't do so already: Set AppCompat theme in your manifest application tag:
<application
...
android:theme="@style/Theme.AppCompat">
And inherit AppCompat at your styles.xml as root for your activity styles etc.:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"/>