page.title=Notepad Tutorial
@jd:body


<p>This tutorial on writing a notepad application gives you a &quot;hands-on&quot; introduction
to the Android framework and the  tools you use to build  applications on it.
Starting from a preconfigured project file, it guides you through the process of
developing a simple notepad application and provides concrete examples of how to
set up the project,  develop the application logic and user interface, and then
compile and run the application. </p>

<p>The tutorial presents the application development as a set of 
exercises (see below), each consisting of several steps. You should follow 
the steps in each exercise to gradually build and refine your  
application. The exercises explain each step in detail and provide all the 
sample code you need to complete the application. </p>

<p>When you are finished with the tutorial, you will have created a functioning
Android application and will have learned many of the most important
concepts in Android development. If you want to add more complex features to
your application, you can examine the code in an alternative implementation
of a Note Pad application, in the 
<a href="{@docRoot}resources/samples/index.html">Sample Code</a> section. </p>


<a name="who"></a>
<h2>Who Should Use this Tutorial</h2>

<p>This tutorial is designed for  experienced developers, especially those with 
knowledge of the Java programming language. If you haven't written Java
applications before, you can still use the tutorial, but you might need to work
at a slower pace. </p>

<p>Also note that this tutorial uses
the Eclipse development environment, with the Android plugin installed. If you
are not using Eclipse, you can  follow  the exercises and build the application,
but you will need to determine how to accomplish the Eclipse-specific
steps in your environment. </p>

<a name="preparing"></a>
<h2>Preparing for the Exercises</h2>

<p>The tutorial  assumes that you have some familiarity with basic Android
application concepts and terminology. If you are not, you
should read <a href="{@docRoot}guide/topics/fundamentals.html">Application 
Fundamentals</a> before continuing. </p>

<p>This tutorial also builds on the introductory information provided in the 
<a href="{@docRoot}resources/tutorials/hello-world.html">Hello World</a>
tutorial, which explains how to set up your Eclipse environment
for building Android applications. We recommend you complete the Hello World
tutorial before starting this one.</p>

<p>To prepare for this lesson:</p>

<ol>
  <li>Download the <a href="codelab/NotepadCodeLab.zip">project
      exercises archive (.zip)</a>.</li>
  <li>Unpack the archive file to a suitable location on your machine.</li>
  <li>Open the <code>NotepadCodeLab</code> folder.</li>
</ol>

<p>Inside the <code>NotepadCodeLab</code> folder, you should see six project
files: <code>Notepadv1</code>,
    <code>Notepadv2</code>, <code>Notepadv3</code>,
    <code>Notepadv1Solution</code>, <code>Notepadv2Solution</code>
    and <code>Notepadv3Solution</code>. The <code>Notepadv#</code> projects are
the starting points for each of the exercises, while the
<code>Notepadv#Solution</code> projects are the exercise
    solutions. If you are having trouble with a particular exercise, you
    can compare your current work against the exercise solution.</p>

<a name="exercises"></a>
<h2> Exercises</h2>

  <p>The table below lists the tutorial exercises and describes the development
areas that each covers. Each exercise assumes that you have completed any
previous exercises.</p>

  <table border="0" style="padding:4px;spacing:2px;" summary="This
table lists the
tutorial examples and describes what each covers. ">
    <tr>
      <th width="120"><a href="{@docRoot}resources/tutorials/notepad/notepad-ex1.html">Exercise
1</a></th>
      <td>Start here. Construct a simple notes list that lets the user add new notes but not
edit them. Demonstrates the basics of <code>ListActivity</code> and creating
and handling
      menu options. Uses a SQLite database to store the notes.</td>
    </tr>
    <tr>
      <th><a href="{@docRoot}resources/tutorials/notepad/notepad-ex2.html">Exercise 2</a></th>
      <td>Add a second Activity to the
application. Demonstrates constructing a
new Activity, adding it to the Android manifest, passing data between the
activities, and using more advanced screen layout. Also shows how to
invoke another Activity to return a result, using
<code>startActivityForResult()</code>.</td>
    </tr>
    <tr>
      <th><a href="{@docRoot}resources/tutorials/notepad/notepad-ex3.html">Exercise 3</a></th>
      <td>Add handling of life-cycle events to
the application, to let it
maintain application state across the life cycle. </td>
    </tr>
    <tr>
    <th><a href="{@docRoot}resources/tutorials/notepad/notepad-extra-credit.html">Extra
Credit</a></th>
    <td>Demonstrates how to use the Eclipse
debugger and how you can use it to
view life-cycle events as they are generated. This section is optional but
highly recommended.</td>
    </tr>
</table>


<a name="other"></a>
<h2>Other Resources and Further Learning</h2>
<ul>
<li>For a lighter but broader introduction to concepts not covered in the
tutorial,
take a look at <a href="{@docRoot}resources/faq/commontasks.html">Common Android Tasks</a>.</li>
<li>The Android SDK includes a variety of fully functioning sample applications
that make excellent opportunities for further learning. You can find the sample
applications in the <code>samples/</code> directory of your downloaded SDK, or browser them
here, in the <a href="{@docRoot}resources/samples/index.html">Sample Code</a> section.</li>
<li>This tutorial draws from the full Notepad application included in the
<code>samples/</code> directory of the SDK, though it does not match it exactly. 
When you are done with the tutorial,
it is highly recommended that you take a closer look at this version of the Notepad
application, 
as it demonstrates a variety of interesting additions for your application, 
such as:</li>
  <ul>
    <li>Setting up a custom striped list for the list of notes.</li>
    <li>Creating a custom text edit view that overrides the <code>draw()</code>
    method to make it look like a lined notepad.</li>
    <li>Implementing a full <code>ContentProvider</code> for notes.</li>
    <li>Reverting and discarding edits instead of just automatically saving
    them.</li>
  </ul>
</ul>
