How can I use the context action bar in the Android support library?

I have a ListView in my ActionBarActivity, which has items that can be held for a long time for additional actions.

I am currently using registerForContextMenu and showing an ugly popup dialog, so I want to change it to use the console action bar.

How can i do this? CHOICE_MODE_MULTIPLE_MODAL, as well as some other things, seem like API 11+.

+7
android android-actionbar
source share
2 answers

What you want to use is ActionMode, http://developer.android.com/reference/android/support/v7/view/ActionMode.html , to implement an action context bar. ActionMode is available in the ActionBarCompat library. In particular, you are using ActionBarActivity # startSupportActionMode.

You can get a brief introduction to this document, http://android-developers.blogspot.com/2013/08/actionbarcompat-and-io-2013-app-source.html . See Section "7. Add ActionMode Callbacks."

A more complete guide is available here, http://developer.android.com/guide/topics/ui/menus.html#CAB .

+8
source share

The Android API Guide for the menu (on the same page as Matt indicates) indicates that:

Note. Contextual action mode is available on Android 3.0 (API level 11) and higher and is the preferred method for displaying contextual actions when they are available. If your application supports versions below 3.0, you should return to the floating context menu on these devices.

If this is still the case, then that means Android does not support context action panels below API level 8. Can anyone confirm if they used it for Froyo or below?

+1
source share

All Articles