Chapter 5. Displaying Pictures and Menus with Views

WHAT YOU WILL LEARN IN THIS CHAPTER

  • How to use the Gallery, ImageSwitcher, GridView, and ImageView views to display images

  • How to display options and context menus

  • How to display time using the AnalogClock and DigitalClock views

  • How to display Web content using the WebView

In the previous chapter, you learned about the various views that you can use to build the user interface of your Android application. In this chapter, you continue your exploration of the other views that you can use to create robust and compelling applications.

In particular, you shall turn your attention to views that enable you to display images. In addition, you will also learn how to create option and context menus in your Android application. This chapter ends with a discussion of some nice views that enable you to display the current time and Web content.

USING IMAGE VIEWS TO DISPLAY PICTURES

So far, all the views you have seen until this point are used to display text information. For displaying images, you can use the ImageView, Gallery, ImageSwitcher, and GridView views.

The following sections discuss each view in more detail.

Gallery and ImageView Views

The Gallery is a view that shows items (such as images) in a center-locked, horizontal scrolling list. Figure 5-1 shows how the Gallery view looks when it is displaying some images.

FIGURE 5-1

Figure 5-1. FIGURE 5-1

The following ...

Get Beginning Android™ Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.