Lists Menus and Other Views

Companies. Click here for terms of use.

Key Skills & Concepts

• Building Activities

• Using Android Menus

• Using the AutoCompleteTextView

This chapter provides a more in-depth treatment of Views and Intents, which arguably are the most important features you should master as a newcomer to Android. These two entities will make up the majority of your early Activities. Almost every Activity you create will have more than one View, and most of them will also need to call an Intent or two.

The best way to learn the most about these topics is to take a very hands-on approach. Reading about these topics and reviewing a list of attributes is one thing, but implementing the code on your own is something entirely different. That is, just as you have done in the previous chapters, you are going to build an Activity that uses Views and Intents rather heavily. By building this application, you will get the best experience with Views and Intents.

The previous two chapters briefly introduced both Views and Intents by having you create very simple Activities that exploited the basic functions of a handful of example Views and Intents. In this chapter, you are going to build a slightly more complex Activity that uses Intents to call new Activities, which you will also create. These new Activities will showcase most of the Views that are available in the current version of the Android SDK. This chapter explains the basic functionality of these Views, such as AutoComplete lists and Galleries, and introduces variations of each View attribute for each Activity.

To begin, create a new Eclipse project named AndroidViews. Create the project with the parameters shown in the following illustration: a Package Name of android_ programmers_guide.AndroidViews, an Activity Name of AndroidViews, and an Application Name of AndroidViews.

w N ew An d ro i d P roj e ct

= 11 II^I

New Android Project

■ y.vV"1

Creates a new Android Project resource.

Project name: AndroidViews Contents

L«) Create new project in workspace ■ ■ Create project from existing source 0 Use default location

Location; | Ci/Users/JFDiMarzio/workspace/AndroidViews | | Browse,

Project name: AndroidViews Contents

L«) Create new project in workspace ■ ■ Create project from existing source 0 Use default location

Location; | Ci/Users/JFDiMarzio/workspace/AndroidViews | | Browse,

Properties

Package name: android_programmers_guide,AndroidViews Activity, name: AndroidViews Application name: AndroidViewsj

Finish creating the project and open the main.xml file. Remove the Hello World! code from main.xml. With the project created and main.xml cleaned, you can begin to add your code.

0 0

Post a comment