0

I'm trying to display the ActionBar on my API 8 emulator by using the v7 AppCompat library, But it's not showing. Even the Split Action Bar does not show. The user has to click the menu button to show the options. I need 4 of the options to always be visible on my screen.

EDIT::

I have android:uiOptions="splitActionBarWhenNarrow", in case it helps...

Here is my menu xml code:

<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:symagine="http://schemas.android.com/apk/res-auto" > <item android:id="@+id/action_twitter" android:icon="@drawable/ic_action_twitter_icon" android:orderInCategory="1" android:showAsAction="always" symagine:showAsAction="always" android:title="@string/twitter_desc"/> <item android:id="@+id/action_share" android:icon="@drawable/ic_action_share" android:orderInCategory="5" android:showAsAction="always" symagine:showAsAction="always" android:title="@string/share_desc"/> <item android:id="@+id/action_rightDrawer" android:icon="@drawable/ic_action_i" android:orderInCategory="6" android:showAsAction="always" symagine:showAsAction="always" android:title="@string/action_info"/> <item android:id="@+id/action_facebook" android:icon="@drawable/facebook_icon" android:orderInCategory="2" android:showAsAction="always" symagine:showAsAction="always" android:title="@string/facebook_desc"/> <item android:id="@+id/action_contact" android:orderInCategory="3" android:showAsAction="collapseActionView" symagine:showAsAction="collapseActionView" android:title="@string/action_contact"/> <item android:id="@+id/about_us" android:orderInCategory="4" android:showAsAction="collapseActionView" symagine:showAsAction="collapseActionView" android:title="@string/action_about_us"/> </menu> 

Here is my HomeActivity Code:

@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.home, menu); return true; } 

My custom action bar theme:

<style name="MyActionBarTheme" parent="@style/Theme.AppCompat"> <item name="android:windowActionBarOverlay" tools:ignore="NewApi">true</item> <item name="android:actionBarStyle" tools:ignore="NewApi">@style/MyCustomActionBar</item> <!-- Support Library Compatibility --> <item name="windowActionBarOverlay">true</item> <item name="actionBarStyle">@style/MyCustomActionBar</item> </style> <style name="MyCustomActionBar" parent="@style/Widget.AppCompat.ActionBar"> <item name="android:background">@android:color/transparent</item> <item name="android:backgroundSplit" tools:ignore="NewApi">@android:color/transparent</item> <item name="android:logo" tools:ignore="NewApi">@drawable/ic_logo</item> <item name="android:displayOptions" tools:ignore="NewApi">showHome|useLogo</item> <!-- Support Library Compatibility --> <item name="background">@android:color/transparent</item> <item name="backgroundSplit">@android:color/transparent</item> <item name="logo">@drawable/ic_logo</item> <item name="displayOptions">showHome|useLogo</item> </style> 

Please can anyone tell me what's the problem? I looked at some previous questions and saw that you need to add [yourapp] namespace in showAsAciton. I did that but it still didnt make a difference. Thank you for your help.

4
  • Remove from menu xml every line with "android:showAsAction="xxx"" Commented Dec 25, 2013 at 7:09
  • yeah but if i do that, the menu won't even show on my phone which is running android 4.2.1 Commented Dec 25, 2013 at 7:13
  • It should be shown, because symagine:showAsAction using for backward compatibility. You can create new android project with NavigationDrawer in Android studio and take a look how it works :) Commented Dec 25, 2013 at 7:21
  • Im using eclipse and it shows if i type both. Commented Dec 25, 2013 at 7:25

2 Answers 2

9

guys! I found the solution. Apparently I wasn't extending ActionBarActivity so the ActionBar wasn't showing on devices less than Android 3.0.

Just thought you guys should know. I was earlier extending FragmentActivity and thought that if I changed it to ActionBarActivity, my Fragments which were running would not work...

But, it turns out that ActionBarActivity extends FragmentActivity so you needn't worry of the fact that one or the other might not work. Hope this helps someone out there!

Merry Christmas!!

Sign up to request clarification or add additional context in comments.

1 Comment

Please set this as the answer.
-1

You need to use a support library like actionbarsherlock. I think this tutorial will help you.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.