Вопрос

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?

Это было полезно?

Решение

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!

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top