
super.onCreate(icicle);
setContentView(R.layout.main);
}
}
Things to note about this source snippet:
• SaySomething is a normal Java class, with a package and imports, as
expected.
• SaySomething extends a base Android class named Activity, which is
located in the android.app package.
• The onCreate() method is the entry point to this activity, receiving an
argument of type Bundle. The Bundle is a class which is essentially a
wrapper around a map or hashmap. Elements required for construction
are passed in this parameter. This tutorial does not examine this
parameter.
• The setContentView(..) is responsible for creating the primary UI
using the R.layout.main argument. This is an identifier representing the
main layout found in the resources of the application.
The next section reviews the resources for the sample application.
Resources for the application
Resources in Android are organized into a subdirectory of the project named res, as
described previously. Resources fall into three primary categories:
Drawables
This folder contains graphics files, such as icons and bitmaps
Layouts
This folder contains XML files that represent the layouts and views of the
application. These will be examined in detail below.
Values
This folder contains a file named strings.xml. This is the primary means for
string localization for the application.
The next section dissects the main.xml file to review the sample application's
primary UI resources.
main.xml
developerWorks® ibm.com/developerWorks
Develop Android applications with Eclipse
Page 16 of 35 © Copyright IBM Corporation 1994, 2008. All rights reserved.
Kommentare zu diesen Handbüchern