Error inflating class fragment

后端 未结 30 2681
长发绾君心
长发绾君心 2020-11-22 14:38

I get the Error

Unable to start activity ComponentInfo{de.androidbuch.activiti/de.androidbuch.activiti.task.Activity}: android.view.InflateException: Binar         


        
30条回答
  •  Happy的楠姐
    2020-11-22 14:43

    I was receiving this error for different reasons.

    Steps to reproduce:

    ~> My issue was that I created a brand new blank application.

    ~> I then generated a custom fragment from the File ~> New File Menu.

    ~> Proceeded to customize the fragment by adding layouts and buttons etc.

    ~> Referenced the new custom fragment in the auto generated activity_my.xml that was generated for me when creating the application. Doing this allowed the XML to generate the objects for me.

    Heres is the catch when generating the custom fragment via File ~> New File Menu it auto generates an interface function stub and places it at the bottom of the fragment class file.

    This means that your MyActivity class must implement this interface. If it does not then the the above error occurs only when referencing the fragment from xml. By removing the reference for the Fragment in the XML completely, and creating the fragment through code in the MyActivity.java class file Logcat generates a more concise error explaining the issue in detail and complaining about the interface. This is demonstrated in the Project Template Activity+Fragment. Although, <~that Project Template does not generate the interface stub.

提交回复
热议问题