page.title=Using Code Templates @jd:body
The SDK tools provide templates for quickly creating Android application projects with the basic structure or for adding components to your existing projects. The code templates provided by the Android SDK follow the Android design and development guidelines to get you on the right track to creating a beautiful, functional application.
There are several types of Android code templates, which can create anything from an entire application down to specific application components. The main categories of code templates are as follows:
Application templates create basic Android applications that you can immediately run and test on your Android device. These templates are available when you create a new Android project, though you can also use these templates to add new activities to an existing project.
To use Android application templates:
Note: The other activity template options also create applications, however these applications require further modification before they can be launched on an Android device.
Example | Description |
---|---|
The BlankActivity template with the Navigation Type: None option creates a simple application that follows the Android Design guidelines. Use this template to create a basic, minimal app as a starting point for your project. This template includes:
|
|
The BlankActivity template with the Navigation Type: Tabs or Tabs + Swipe option creates an application with three sections based on the {@link android.app.Fragment} class and a tabbed user interface. This template includes:
|
|
The BlankActivity template with the Navigation Type: Swipe Views + Title Strip option creates an application with three {@link android.app.Fragment} sections, a compact title strip header (known as Scrollable Tabs in the Android Design guide) and swipe navigation between the sections, based on the swipe view design pattern. This template includes:
|
|
The BlankActivity template with the Navigation Type: Dropdown option creates an application that extends {@link android.support.v4.app.FragmentActivity}, containing three {@link android.app.Fragment} sections, with an {@link android.app.ActionBar} using list mode navigation. This template includes:
|
Example | Description |
---|---|
This template provides an implementation of an activity which alternates between a primary, full screen view and a view with standard user interface controls, including the notification bar and application title bar. The full screen view is the default and a user can activate the standard view by touching the device screen. This template includes:
|
Example | Description |
---|---|
This template creates an adaptive layout for a set of items and associated details. On a tablet device, the item list and item details are displayed on the same screen. On a smaller device, the list and details are displayed on separate screens. Note: This template follows the recommendations of the Designing for Multiple Screens Android training. This template includes:
|
Android activity templates provide options to add new activities to your existing application.
To use Android activity templates:
These templates create the same type of activity as they do when used as an application template, however the following templates create activities which are specifically intended to be used as part of an existing application.
Example | Description |
---|---|
This activity template provides input fields and a sample implementation of an {@link android.os.AsyncTask} that asks users to login or register with their credentials. This template includes:
|
Example | Description |
---|---|
This template extends the {@link android.preference.PreferenceActivity} class and uses an XML file to create preference settings. This template also demonstrates how to implement several data types for settings. This template includes:
|
Android object templates provide options to add new components to your existing application, including the previously mentioned activities as well as the following additional items:
To use Android object templates: