1 excludeFromSuggestions=true 2 page.title=Notepad Tutorial 3 parent.title=Tutorials 4 @jd:body 5 6 7 <p>This tutorial on writing a notepad application gives you a "hands-on" introduction 8 to the Android framework and the tools you use to build applications on it. 9 Starting from a preconfigured project file, it guides you through the process of 10 developing a simple notepad application and provides concrete examples of how to 11 set up the project, develop the application logic and user interface, and then 12 compile and run the application. </p> 13 14 <p>The tutorial presents the application development as a set of 15 exercises (see below), each consisting of several steps. You should follow 16 the steps in each exercise to gradually build and refine your 17 application. The exercises explain each step in detail and provide all the 18 sample 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 21 Android application and will have learned many of the most important 22 concepts 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 28 knowledge of the Java programming language. If you haven't written Java 29 applications before, you can still use the tutorial, but you might need to work 30 at a slower pace. </p> 31 32 <p>Also note that this tutorial uses 33 the Eclipse development environment, with the Android plugin installed. If you 34 are not using Eclipse, you can follow the exercises and build the application, 35 but you will need to determine how to accomplish the Eclipse-specific 36 steps 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 42 application concepts and terminology. If you are not, you 43 should read <a href="{@docRoot}guide/components/fundamentals.html">Application 44 Fundamentals</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> 48 tutorial, which explains how to set up your Eclipse environment 49 for building Android applications. We recommend you complete the Hello World 50 tutorial 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 62 files: <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 66 the 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 75 areas that each covers. Each exercise assumes that you have completed any 76 previous exercises.</p> 77 78 <table border="0" style="padding:4px;spacing:2px;" summary="This 79 table lists the 80 tutorial examples and describes what each covers. "> 81 <tr> 82 <th width="120"><a href="{@docRoot}training/notepad/notepad-ex1.html">Exercise 83 1</a></th> 84 <td>Start here. Construct a simple notes list that lets the user add new notes but not 85 edit them. Demonstrates the basics of <code>ListActivity</code> and creating 86 and 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 92 application. Demonstrates constructing a 93 new Activity, adding it to the Android manifest, passing data between the 94 activities, and using more advanced screen layout. Also shows how to 95 invoke 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 101 the application, to let it 102 maintain application state across the life cycle. </td> 103 </tr> 104 <tr> 105 <th><a href="{@docRoot}training/notepad/notepad-extra-credit.html">Extra 106 Credit</a></th> 107 <td>Demonstrates how to use the Eclipse 108 debugger and how you can use it to 109 view life-cycle events as they are generated. This section is optional but 110 highly 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 119 tutorial, 120 take 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 124 match it exactly. When you are done with the tutorial, it is highly recommended 125 that you take a closer look at this version of the Notepad application, as it 126 demonstrates a variety of interesting additions for your application, such 127 as:</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