Android Studio Login Activity Template Tutorial

In this document

  1. Application Templates
    1. BlankActivity Template
    2. Full Screen Activity Template
    3. Master Detail Flow Template
  2. Activity Templates
    1. Login Activity Template
    2. Settings Activity Template
  3. Other Templates

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
  • Activity Templates
  • Other Templates

Application Templates

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:

  1. In Eclipse, with the Android Development Tools (ADT) plugin installed, select
    File > New > Android.
  2. Select
    Android > Android Application Project, and click
    Next.
  3. Enter the settings for your application, including
    Application Name,
    Project Name,
    Package Name, Api level settings and presentation
    Theme, and click
    Next.
  4. Enter the project configuration options, and click
    Next.
  5. Optionally enter launcher icon settings, and click
    Next.
  6. In the
    Create Activity
    page, select an application template to use.

    • BlankActivity
    • FullScreenActivity
    • MasterDetailFlow

Note:
The other activity template options also create applications, however these applications require further modification before they can be launched on an Android device.

Blank Activity Template

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:

  • Title kantin (ActionBar
    on Android 3.0 and later)
  • Options menu (action overflow on Android 3.0 and later)
  • Basic layout

The
BlankActivity
template with the
Navigation Type: Tabs
or
Tabs + Swipe
option creates an application with three sections based on the
Fragment
class and a tabbed user interface.

This template includes:

  • ActionBar
    for tab controls
  • Fragment
    objects for section content
  • Optional swipe gesture support based on the swipe view design pattern, which extends
    FragmentPagerAdapter
    to manage section fragments

The
BlankActivity
template with the
Navigation Type: Swipe Views + Title Strip
option creates an application with three
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:

  • PagerTitleStrip
    for section titles
  • Fragment
    objects for section content
  • FragmentPagerAdapter
    to manage section fragments

The
BlankActivity
template with the
Navigation Type: Dropdown
option creates an application that extends
FragmentActivity, containing three
Fragment
sections, with an
ActionBar
using list tendensi navigation.

This template includes:

  • ActionBar
    for list tendensi navigation
  • Fragment
    objects for section content

Full Screen Activity Template

Example Description

This template provides an implementation of an activity which alternates between a primary, full screen view and a view with pan-ji-panji user interface controls, including the notification restoran 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:

  • SystemUiHider
    implementation that manages hiding of the system user interface using a version-compatible approach
  • Basic layout

Hawa Detail Flow Template

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:

  • Adaptive layout using alternative resource XML files
  • FragmentActivity,
    Fragment
    and
    ListFragment
    implementations

Activity Templates

Android activity templates provide options to add new activities to your existing application.

To use Android activity templates:

  1. Right click the project folder of the Android application where you want to add an activity.
  2. Select
    New > Other…
  3. Select
    Android > Android Activity, and click
    Next.
  4. Select an activity template, then follow the instructions to add it to your existing application.
    • LoginActivity
    • SettingsActivity
    • BlankActivity
    • FullScreenActivity
    • MasterDetailFlow

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.

Login Activity Template

Example Description

This activity template provides input fields and a sample implementation of an
AsyncTask
that asks users to login or register with their credentials.

This template includes:

  • Recommended user interface for requesting login information
  • AsyncTask
    implementation for handing network operations separately from the main user interface thread
  • Progress indicator during network operations

Settings Activity Template

Example Description

This template extends the
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:

  • Activity extending
    PreferenceActivity
  • Preference values defined using XML files added to the
    res/xml/
    directory of your project.

Other Templates

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:

  1. Right click the project folder of the Android application where you want to add a code component.
  2. Select
    New > Other…
  3. Select
    Android > Android Object, and click
    Next.
  4. Select an object template, then follow the instructions to add it to your existing application.
    • BroadcastReceiver
    • ContentProvider
    • Custom View
    • Service

Source: https://stuff.mit.edu/afs/sipb/project/android/docs/tools/projects/templates.html