Error Inflating Class Com.android.internal.widget.actionbarcontainer
Solution 1:
Here is how I solved this error:
In the styles.xml file, in the first "AppTheme" style I had to put Base infront of Theme.AppCompat. So it would be "Base.Theme.AppCompat.Light.DarkActionBar".
Then I used android:theme="@style/AppTheme" in my parent activity in androidmanifest.xml.
In the androidmanifest file in the child activity, I had to put android:parentActivityName=".parentActivity" and I removed android:theme="@style/AppTheme.AppBarOverlay" from the child activity and put it in the activity.xml (child activity) file as below.
In the activity.xml file in the LinearLayout tag, I had to put android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar". It is the parent of the "@style/AppTheme.AppBarOverlay".
This 4 step process worked for me, and if you are getting this error, just follow these steps and it should work for you as well.
Edit: It turned out that the solution was very simple. To have an action bar in any of your activities, you just need to extend AppCompatActivity. Only my main activity was extending AppCompatActivity and not other activities. The above approach for getting an action bar is quite vague and I knew it, however, it worked initially, but now I have the correct and straight forward solution and if you are getting such error then just check that whether you are extending AppCompatActivity in your class or not.
Solution 2:
You set a ThemeOverlay as your Activity theme. ThemeOverlay only specifies certain attributes so when used on a widget it overlays these attributes over the original activity or parent widget theme. Your Activity must use a full fledged Theme such as your AppTheme
.
This is probably what you were looking for:
values/styles.xml
<stylename="AppTheme"parent="AppBaseTheme"><itemname="actionBarTheme">@style/AppTheme.AppBarOverlay</item><itemname="actionBarPopupTheme">@style/AppTheme.PopupOverlay</item></style>
AndroidManifest.xml
<activityandroid:theme="@style/AppTheme"></activity>
Post a Comment for "Error Inflating Class Com.android.internal.widget.actionbarcontainer"