0

I am using the actiobarcompat sample in my application and I am trying to implement search for pre 3.0 devices.

<menu xmlns:android="http://schemas.android.com/apk/res/android" >

<item
    android:id="@+id/menu_search"
    android:orderInCategory="1"
    android:title="@string/menu_search"
    android:icon="@drawable/ic_home"
    android:showAsAction="collapseActionView|ifRoom"
    android:actionViewClass="android.widget.SearchView" />

</menu>

On Honeycomb+ this works fine, the searchview widget appears in the actionbar. What I am trying to do is have a second menu XML so I can fall back to the old search activity way of doing it. However, there is no such thing as menu-v11 folder as the menu folder is essentially menu-v11 because that is the version it started supporting this.

My question is, using the actionbar compatibility sample, is there a way to declaratively add an alternate button for pre-honeycomb?

Tom Fobear
  • 6,729
  • 7
  • 42
  • 74
  • 1
    Have you considered using ActionBar Sherlock? – Brett Duncavage Apr 05 '13 at 02:43
  • I have.. they ARE both Apache... its complicated though. I am walking the line of if the suits are going to allow me to use either of these components in the first place. it may be all for naught. – Tom Fobear Apr 05 '13 at 02:50
  • @TomFobear: Well ABS (ActionBarSherlock) is under a Apache License if that is what you meant. And if it all hinges on the _suits_ accepting the use of such a lib, you should put all the options on the table. If they need the feature, they will need to choose, I suspect, most probably ABS. – Siddharth Lele Apr 05 '13 at 03:06
  • 1
    What's the problem with using Apache Licensed libraries? Many commercial apps use ActionBar Sherlock, Foursquare does, for example. It's not GPL. – Brett Duncavage Apr 05 '13 at 03:18

1 Answers1

0

Can you please be more specific about what you are trying to achieve?

It it's about calling different activities depending on API version, the action bar has nothing to do with that. You analyse API version in onOptionsItemSelected and act accordingly.

If you want different menu items depending on API version, just create a folder menu-v11 (or menu-v14) and put version-specific xml-s- there.

BTW, I use com.android.actionbarcompat and it works great for me!

cyanide
  • 3,885
  • 3
  • 25
  • 33
  • I've actually figured out a solution to my specific problem but would prefer to not answer my own question. The problem is in ActionBarHelperBase in method loadActionBarMetadata it will only add the menu item if it is shown always or ifRoom.. but not the OR'd combination of collapseActionItem and ifRoom. – Tom Fobear Apr 05 '13 at 06:22