Actionbar Not Shown with Appcompat

Android - Action Bar doesn't show up using Theme.AppCompat

My answer should be as a comment but this is the only way I can reply.
Are you extending ActionBarActivity in your activity?
Have you tried the show() method in your activity?

Actionbar not shown with AppCompat

Use the compat name space for your menu items like this:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:compat="http://schemas.android.com/apk/res-auto" >
<item android:id="@+id/action_whatever"
android:icon="@drawable/ic_action_whatever"
android:title="@string/whatever"
compat:showAsAction="ifRoom" />
</menu>

Logo are not displayed in Actionbar, using AppCompat

I removed all the android:logo attributes from my AndroidManifest.xml and I modified my MyActionBarLogo style like this:

<style name="MyActionBarLogo" parent="@style/Widget.AppCompat.Light.ActionBar">
<item name="background">@color/mainColor500</item>
<item name="logo">@drawable/actionbar_logo</item>
<item name="displayOptions">useLogo|showHome</item>
</style>

Now the actionbar is displaying my logo. :)

Action bar not showing :Theme.Appcompat.Light.DarkActionBar in preference activity

PreferenceActivity does not extend ActionBarActivity, which is required for action bar to be available.

If you need a preferences screen with action bar, try to use PreferenceFragment inside an ActionBarActivity instead.

public class SettingsActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Display the fragment as the main content.
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new SettingsFragment())
.commit();
}
}

public static class SettingsFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
}
...
}

Reference: http://developer.android.com/guide/topics/ui/settings.html#Fragment

Android studio action bar not showing in new activity

try above in style.xml

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

and update your AndroidManifest file like above

  <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.karanvir.search">
<uses-permission android:name="android.permission.INTERNET"/>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Main2Activity"
android:label="@string/title_activity_main2"
/>
<activity
android:name=".Yahoo"
android:label="@string/title_activity_yahoo"
></activity>
</application>

How To Show and hide ActionBar with AppCompat v.7

In the activities where you want to have no action bar use a theme derived from Theme.AppCompat.NoActionBar or Theme.AppCompat.Light.NoActionBar. This activity will never be able to show the action bar unless you supply your own via setSupportActionBar(Toolbar).

In the activities where you want to have the action bar use a theme derived from Theme.AppCompat, Theme.AppCompat.Light or Theme.AppCompat.Light.DarkActionBar. This will allow you to dynamically hide or show the action bar in such activity. You will not be able to supply your own action bar using these themes.

When working with appcompat-v7 action bar you need to obtain it by calling getSupportActionBar() instead of getActionBar().

AppCompat - Item not showing in action bar for API levels v8-13

Try to put the code for MenusHelper.displayMenu(this, menu); into the onCreateOptionsMenu() rather than onPrepareOptionsMenu() and also do the necessary modification.

@Override
public boolean onCreateOptionsMenu(Menu menu) {

getMenuInflater().inflate(R.menu.menu, menu);

// In case you have an item
MenuItem shareItem = menu.findItem(R.id.menu_share);

// To retrieve the Action Provider
mActionProvider = (ShareActionProvider)
MenuItemCompat.getActionProvider(shareItem);

return super.onCreateOptionsMenu(menu);
}

Make sure your Menu in your XML looks like this:

<item
android:id="@+id/share"
android:title="@string/menu_share"
yourapp:actionProviderClass="android.support.v7.widget.ShareActionProvider"
yourapp:showAsAction="ifRoom|withText"/>


Related Topics



Leave a reply



Submit