1excludeFromSuggestions=true
2page.title=Notepad Tutorial
3parent.title=Tutorials
4@jd:body
5
6
7<p>This tutorial on writing a notepad application gives you a &quot;hands-on&quot; introduction
8to the Android framework and the  tools you use to build  applications on it.
9Starting from a preconfigured project file, it guides you through the process of
10developing a simple notepad application and provides concrete examples of how to
11set up the project,  develop the application logic and user interface, and then
12compile and run the application. </p>
13
14<p>The tutorial presents the application development as a set of
15exercises (see below), each consisting of several steps. You should follow
16the steps in each exercise to gradually build and refine your
17application. The exercises explain each step in detail and provide all the
18sample code you need to complete the application. </p>
19
20<p><p>When you are finished with the tutorial, you will have created a functioning
21Android application and will have learned many of the most important
22concepts in Android development.</p>
23
24<a name="who"></a>
25<h2>Who Should Use this Tutorial</h2>
26
27<p>This tutorial is designed for  experienced developers, especially those with
28knowledge of the Java programming language. If you haven't written Java
29applications before, you can still use the tutorial, but you might need to work
30at a slower pace. </p>
31
32<p>Also note that this tutorial uses
33the Eclipse development environment, with the Android plugin installed. If you
34are not using Eclipse, you can  follow  the exercises and build the application,
35but you will need to determine how to accomplish the Eclipse-specific
36steps in your environment. </p>
37
38<a name="preparing"></a>
39<h2>Preparing for the Exercises</h2>
40
41<p>The tutorial  assumes that you have some familiarity with basic Android
42application concepts and terminology. If you are not, you
43should read <a href="{@docRoot}guide/components/fundamentals.html">Application
44Fundamentals</a> before continuing. </p>
45
46<p>This tutorial also builds on the introductory information provided in the
47<a href="{@docRoot}training/basics/firstapp/index.html">Building Your First App</a>
48tutorial, which explains how to set up your Eclipse environment
49for building Android applications. We recommend you complete the Hello World
50tutorial before starting this one.</p>
51
52<p>To prepare for this lesson:</p>
53
54<ol>
55  <li>Download the <a href="codelab/NotepadCodeLab.zip">project
56      exercises archive (.zip)</a>.</li>
57  <li>Unpack the archive file to a suitable location on your machine.</li>
58  <li>Open the <code>NotepadCodeLab</code> folder.</li>
59</ol>
60
61<p>Inside the <code>NotepadCodeLab</code> folder, you should see six project
62files: <code>Notepadv1</code>,
63    <code>Notepadv2</code>, <code>Notepadv3</code>,
64    <code>Notepadv1Solution</code>, <code>Notepadv2Solution</code>
65    and <code>Notepadv3Solution</code>. The <code>Notepadv#</code> projects are
66the starting points for each of the exercises, while the
67<code>Notepadv#Solution</code> projects are the exercise
68    solutions. If you are having trouble with a particular exercise, you
69    can compare your current work against the exercise solution.</p>
70
71<a name="exercises"></a>
72<h2> Exercises</h2>
73
74  <p>The table below lists the tutorial exercises and describes the development
75areas that each covers. Each exercise assumes that you have completed any
76previous exercises.</p>
77
78  <table border="0" style="padding:4px;spacing:2px;" summary="This
79table lists the
80tutorial examples and describes what each covers. ">
81    <tr>
82      <th width="120"><a href="{@docRoot}training/notepad/notepad-ex1.html">Exercise
831</a></th>
84      <td>Start here. Construct a simple notes list that lets the user add new notes but not
85edit them. Demonstrates the basics of <code>ListActivity</code> and creating
86and handling
87      menu options. Uses a SQLite database to store the notes.</td>
88    </tr>
89    <tr>
90      <th><a href="{@docRoot}training/notepad/notepad-ex2.html">Exercise 2</a></th>
91      <td>Add a second Activity to the
92application. Demonstrates constructing a
93new Activity, adding it to the Android manifest, passing data between the
94activities, and using more advanced screen layout. Also shows how to
95invoke another Activity to return a result, using
96<code>startActivityForResult()</code>.</td>
97    </tr>
98    <tr>
99      <th><a href="{@docRoot}training/notepad/notepad-ex3.html">Exercise 3</a></th>
100      <td>Add handling of life-cycle events to
101the application, to let it
102maintain application state across the life cycle. </td>
103    </tr>
104    <tr>
105    <th><a href="{@docRoot}training/notepad/notepad-extra-credit.html">Extra
106Credit</a></th>
107    <td>Demonstrates how to use the Eclipse
108debugger and how you can use it to
109view life-cycle events as they are generated. This section is optional but
110highly recommended.</td>
111    </tr>
112</table>
113
114
115<a name="other"></a>
116<h2>Other Resources and Further Learning</h2>
117<ul>
118<li>For a lighter but broader introduction to concepts not covered in the
119tutorial,
120take a look at <a href="{@docRoot}resources/faq/commontasks.html">Common Android Tasks</a>.</li>
121
122<li>This tutorial draws from the full Notepad application included in the
123<code>samples/legacy/NotePad</code> directory of the SDK, though it does not
124match it exactly. When you are done with the tutorial, it is highly recommended
125that you take a closer look at this version of the Notepad application, as it
126demonstrates a variety of interesting additions for your application, such
127as:</li>
128  <ul>
129    <li>Setting up a custom striped list for the list of notes.</li>
130    <li>Creating a custom text edit view that overrides the <code>draw()</code>
131    method to make it look like a lined notepad.</li>
132    <li>Implementing a full <code>ContentProvider</code> for notes.</li>
133    <li>Reverting and discarding edits instead of just automatically saving
134    them.</li>
135  </ul>
136</ul>
137