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