O'Reilly logo

Android Programming: The Big Nerd Ranch Guide by Brian Hardy, Bill Phillips

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing Contextual Action Mode

The code you have written for deleting a crime via a floating context menu will work on any Android device. For instance, Figure 18.2 shows the floating menu on a device running Jelly Bean.

However, the recommended way to present contextual actions on newer devices is to have a long-press on a view put the screen into contextual action mode. When the screen is in contextual action mode, the items defined in your context menu appear in a contextual action bar that overlays the action bar. Contextual action bars are nice because they do not obscure the screen.

Figure 18.3  Contextual action bar appears on long-press

Implementing a contextual action bar requires a different set of code from a floating context ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required