0

When using ActionbarCompat as Actionbar BackPort I am having the problem that action-icons do not show up - same code/res works with actionbarsherlock.

Am I doing something wrong or is this not yet supported? I am also missing the whole Menu/MenuItem getSupportMenuInflater() part that ABS has in ActionBar compat - can anyone shed some light on this?

CSchulz
  • 10,882
  • 11
  • 60
  • 114
ligi
  • 39,001
  • 44
  • 144
  • 244

2 Answers2

5

This question was already answered in Actionbar not shown with AppCompat.

Add the following namespace to the "menu" item in your xml file

xmlns:compat="http://schemas.android.com/apk/res-auto" 

Then change the "showAsAction" attribute to use the new namespace

compat:showAsAction="ifRoom"

Here's a full example with one item in the menu, with the changes on lines 2 and 6 (from Actionbar not shown with AppCompat)

<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>
Community
  • 1
  • 1
avparker
  • 106
  • 1
  • 7
0

When using the new ActionBarActivity, you no longer need getSupportMenuInflator. Your code should look like this:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    return super.onCreateOptionsMenu(menu);
}

When calling invalidateOptionsMenu with ActionBarActivity you do need to use the new support version:

supportInvalidateOptionsMenu();

Those are the only two main differences between ActionBarSherlock and the new ActionBarActivity that I have found.

CSchulz
  • 10,882
  • 11
  • 60
  • 114
blackcj
  • 3,651
  • 2
  • 25
  • 23
  • hm my code was looking that way, but the actions-icons did not show up – ligi Aug 16 '13 at 14:49
  • Can you post your menu xml and onCreate method? Are you extending ActionBarActivity? – blackcj Aug 16 '13 at 14:54
  • really hard to extract and I am basically back to ABS where this just worked out of the box and wait for the AppCompat to mature I think before giving it another try ;-) – ligi Aug 16 '13 at 15:51