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.
API Level 11 introduced a few new capabilities for app widgets, to make them more interactive and more powerful than before. The documentation lags a bit, though, so determining how to use these features takes a bit of exploring. Fortunately for you, the author did some of that exploring on your behalf, to save you some trouble.
Understanding this chapter requires that you have read the preceding chapter and all of its prerequisites.
In addition to the classic widgets available for use in app widgets
RemoteViews, five more were added for API Level 11:
Three of these (
ViewFlipper) are widgets
that existed in Android since the outset.
StackView was added in API Level 11
to provide a “stack of cards” UI:
Figure 730: The Google Books app widget, showing a StackView
AdapterViewFlipper works like a
ViewFlipper, allowing you to
toggle between various children with only one visible at a time.
However, whereas with
ViewFlipper all children are
View objects held by the
AdapterViewFlipper uses the
Adapter model, so only a small number
View objects are held in memory, no matter how many
potential children there are.
With the exception of
ViewFlipper, the other four all require the
use of an
Adapter. This might seem odd, as there is no way to
Adapter to a
RemoteViews. That is true, but API Level 11
added new ways for
Adapter-like communication between the app
widget host (e.g., home screen) and your application. We will take an
in-depth look at that in an upcoming section.
The preview of this section is out seeking fame and fortune as the Dread Pirate Roberts.