How to fix Error inflating class null

前端 未结 2 388
情深已故
情深已故 2021-01-18 00:58

I am trying to make a scrollable tab but when I set a view in my fragment layout the app starts giving error as Error inflating class null.It was working whenthe view is not

相关标签:
2条回答
  • 2021-01-18 01:26

    You need to define the proper package name for the view class. By looking at the package name defined in your class you can define it in your layout xml like this

    <com.example.neelay.anotherbeatbox.Fragment.Songs
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#fff"
        android:layout_marginTop="150dp"/>
    
    0 讨论(0)
  • 2021-01-18 01:35

    Replace

    <view
    

    with

    <View
    

    View is an actual widget you can inflate and seems to fit your intended purpose. view is a special tag and with it you can inflate view classes by a name defined in attributes, and you have not defined such class name (it comes up as null in inflater).

    0 讨论(0)
提交回复
热议问题