InflateException with TextInputLayout and AlertDialog

前端 未结 7 593
被撕碎了的回忆
被撕碎了的回忆 2020-12-11 05:55

I am trying to use the newest TextInputLayout in my DialogFragment.

Here\'s my code:



        
相关标签:
7条回答
  • 2020-12-11 06:46
    • 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"/>
    
    0 讨论(0)
提交回复
热议问题