Skip to content Skip to sidebar Skip to footer

Android Actionbar Missing After Extending Appcompatactivity

I've recently updated my app extending Appcompatactivity in my Activities. Since then, the Actionbar is gone when I launch an external library Intent. For example, I'm using the H

Solution 1:

First, check your theme it may be like below ("NoActionBar"). Then the action bar is not appearing. If this is your issue. please add an appropriate theme for your application

<applicationandroid:theme="@style/Theme.AppCompat.Light.NoActionBar"
    />

if your theme is not a problem, you can add below content to your XML file. (add this as a first child of your XML file)

<android.support.v7.widget.Toolbar
   android:id="@+id/my_toolbar"
   android:layout_width="match_parent"
   android:layout_height="?attr/actionBarSize"
   android:background="?attr/colorPrimary"
   android:elevation="4dp"
   android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
   app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

and add below content to your activity on create method

protectedvoidonCreate(Bundle savedInstanceState) {
    .......
    ToolbarmyToolbar= (Toolbar) findViewById(R.id.my_toolbar);
    setSupportActionBar(myToolbar);
}

Solution 2:

The reason is probably that FeedbackManager.showFeedbackActivity(this, Uri.fromFile(file)) opens a new FeedbackActivity.class which is subclass of Activity.class instead of AppCompatActivity.class, so it can not show the ActionBar.Here is a link https://stackoverflow.com/questions/30681918/nullpointerexception-with-actionbar-setdisplayhomeasupenabledboolean-on-a-nu that explains some reasons.

Post a Comment for "Android Actionbar Missing After Extending Appcompatactivity"