The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.


Action Modes

If you have spent much time on an Android 3.0+ device, then you probably have run into a curious phenomenon. Sometimes, when you select an item in a list or other widget, the action bar magically transforms from its normal look:

Regular Action Bar for Activity with EditText
Figure 470: Regular Action Bar for Activity with EditText

to one designed to perform operations on what you have selected:

Action Mode, Given Selected Word in EditText
Figure 471: Action Mode, Given Selected Word in EditText

The good news is that this is not some sort of magic limited only to built-in widgets like EditText. You too can have this effect in your application, by triggering an “action mode”.

In this chapter, we will explore how you can set up and respond to action modes.

Prerequisites

Understanding this chapter requires that you have read the core chapters, particularly the one on the action bar.

A Matter of Context

The preview of this section was accidentally identified as an Android 'tasty treat' by the Cookie Monster.

Manual Action Modes

The preview of this section was accidentally identified as an Android 'tasty treat' by the Cookie Monster.

Multiple-Choice-Modal Action Modes

The preview of this section is being chased by zombies.

Long-Click To Initiate an Action Mode

The preview of this section was the victim of a MITM ('Martian in the middle') attack.