I have a ListView in my ActionBarActivity that has items that can be long-pressed for additional actions.
I currently am using registerForContextMenu
and showing an ugly popup dialog, so I want to change it to use a contexual action bar.
How can I do this? CHOICE_MODE_MULTIPLE_MODAL as well as a few other things seem to be API 11+.
What you want to use is ActionMode, http://developer.android.com/reference/android/support/v7/view/ActionMode.html, to implement the contextual action bar. The ActionMode is available in the ActionBarCompat library. Specifically you use ActionBarActivity#startSupportActionMode.
You can get a quick introduction in this document, http://android-developers.blogspot.com/2013/08/actionbarcompat-and-io-2013-app-source.html. See the section entitled "7. Add ActionMode callbacks".
A more complete tutorial is available here, http://developer.android.com/guide/topics/ui/menus.html#CAB.
The Android API Guide for menus (same page that Matt cited) states that:
Note: The contextual action mode is available on Android 3.0 (API level 11) and higher and is the preferred technique for displaying contextual actions when available. If your app supports versions lower than 3.0 then you should fall back to a floating context menu on those devices.
If this is still true, then it means that Android does not support contextual action bars below API level 8. Can anyone please confirm if they have used it for Froyo or below?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With