Home | History | Annotate | Download | only in notepad
      1 excludeFromSuggestions=true
      2 page.title=Notepad Tutorial
      3 @jd:body
      4 
      5 
      6 <p>The  tutorial in this section 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 notepad application development as a set of 
     14 exercises (see below), each consisting of several steps. You can follow along 
     15 with the steps in each exercise and gradually build up 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 learned in depth about 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 notepad application, in the 
     24 <a href="{@docRoot}samples/NotePad/index.html">Sample Code</a> documentation. </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>The tutorial  assumes that you have some familiarity with the basic Android
     36 application concepts and terminology. If you aren't yet familiar with those, you
     37 should read <a href="{@docRoot}intro/anatomy.html">Overview of an Android 
     38 Application</a> before continuing. </p>
     39 
     40 <p>Also note that this tutorial uses
     41 the Eclipse development environment, with the Android plugin installed. If you
     42 are not using Eclipse, you can  follow  the exercises and build the application,
     43 but you will need to determine how to accomplish the Eclipse-specific
     44 steps in your environment. </p>
     45 
     46 <a name="preparing"></a>
     47 <h2>Preparing for the Exercises</h2>
     48 
     49 <p>This tutorial builds on the information provided in the <a
     50 href="{@docRoot}intro/installing.html">Installing the SDK</a> and <a 
     51 href="{@docRoot}intro/hello-android.html">Hello Android</a>
     52 documents, which explain in detail how to set up your development environment
     53 for building Android applications. Before you start this tutorial, you should
     54 read both these documents, have the SDK installed, and your work environment set up.</p>
     55 
     56 <p>To prepare for this lesson:</p>
     57 
     58 <ol>
     59   <li>Download the <a href="codelab/NotepadCodeLab.zip">project
     60       exercises archive (.zip)</a></li>
     61   <li>Unpack the archive file to a suitable location on your machine</li>
     62   <li>Open the <code>NotepadCodeLab</code> folder</li>
     63 </ol>
     64 
     65 <p>Inside the <code>NotepadCodeLab</code> folder, you should see six project
     66 files: <code>Notepadv1</code>,
     67     <code>Notepadv2</code>, <code>Notepadv3</code>,
     68     <code>Notepadv1Solution</code>, <code>Notepadv2Solution</code>
     69     and <code>Notepadv3Solution</code>. The <code>Notepadv#</code> projects are
     70 the starting points for each of the exercises, while the
     71 <code>Notepadv#Solution</code> projects are the exercise
     72     solutions. If you are having trouble with a particular exercise, you
     73     can compare your current work against the exercise solution.</p>
     74 
     75 <a name="exercises"></a>
     76 <h2> Exercises</h2>
     77 
     78   <p>The table below lists the tutorial exercises and describes the development
     79 areas that each covers. Each exercise assumes that you have completed any
     80 previous exercises.</p>
     81 
     82   <table border="0" style="padding:4px;spacing:2px;" summary="This
     83 table lists the
     84 tutorial examples and describes what each covers. ">
     85     <tr>
     86       <th width="120"><a href="{@docRoot}intro/tutorial-ex1.html">Exercise
     87 1</a></th>
     88       <td>Start here. Construct a simple notes list that lets the user add new notes but not
     89 edit them. Demonstrates the basics of <code>ListActivity</code> and creating
     90 and handling
     91       menu options. Uses a SQLite database to store the notes.</td>
     92     </tr>
     93     <tr>
     94       <th><a href="{@docRoot}intro/tutorial-ex2.html">Exercise 2</a></th>
     95       <td>Add a second Activity to the
     96 application. Demonstrates constructing a
     97 new Activity, adding it to the Android manifest, passing data between the
     98 activities, and using more advanced screen layout. Also shows how to
     99 invoke another Activity to return a result, using
    100 <code>startActivityForResult()</code>.</td>
    101     </tr>
    102     <tr>
    103       <th><a href="{@docRoot}intro/tutorial-ex3.html">Exercise 3</a></th>
    104       <td>Add handling of life-cycle events to
    105 the application, to let it
    106 maintain application state across the life cycle. </td>
    107     </tr>
    108     <tr>
    109     <th><a href="{@docRoot}intro/tutorial-extra-credit.html">Extra
    110 Credit</a></th>
    111     <td>Demonstrates how to use the Eclipse
    112 debugger and how you can use it to
    113 view life-cycle events as they are generated. This section is optional but
    114 highly recommended.</td>
    115     </tr>
    116 </table>
    117 
    118 
    119 <a name="other"></a>
    120 <h2>Other Resources and Further Learning</h2>
    121 <ul>
    122 <li>For a lighter but broader introduction to concepts not covered in the
    123 tutorial,
    124 take a look at <a href="{@docRoot}kb/commontasks.html">Common Android Tasks</a>.</li>
    125 <li>The Android SDK includes a variety of fully functioning sample applications
    126 that make excellent opportunities for further learning. You can find the sample
    127 applications in the <code>samples/</code> directory of your downloaded SDK.</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
    139     make it look like a lined notepad.</li>
    140   <li>Implementing a full <code>ContentProvider</code> for notes.</li>
    141   <li>Reverting and discarding edits instead of just automatically saving
    142 them.</li>
    143 </ul>
    144 </ul>
    145