|The Android Developer's guide (available at http://developer.android.com/guide/index.html) is an excellent resource for folks looking to develop Android applications. Of course, as is much technical documentation, it's infected with code bugs and errors.|
In particular, this post lists errors in the "Hello, Views > Spinner" tutorial, available at http://developer.android.com/resources/tutorials/views/hello-spinner.html, and includes step-by-step corrections for these problems. This information was communicated to the Android development team in Android Issue 12817.
Link To This Articlehttp://goo.gl/P408h
Step 1: Start a new project named HelloSpinner.
The tutorial author(s)/editor(s) may be assuming the folks following this tutorial are already skilled enough to fill in the missing project creation details. For anyone stuck at this first step, take a look at the initial "Hello, World" tutorial. Following are reasonable values to use for the other fields when creating this new project.
|Build Target:||Android 1.5|
|Application name:||Hello Spinner|
|Min SDK Version:||3|
Concerning step 2, it is (or will be) error free, after the third step is completed. It makes sense to me that steps two and three would be switched, so as to avoid the initial errors reported by Eclipse after completing the second step.
Step 3 introduces a significant error, because it instructs users to delete the
app_namestring resource value, which is actually used by the application. After following step 3 as instructed, save the changes, and notice that Eclipse complains about errors in
AndroidManifest.xmlconcerning missing resource
To correct this problem, instead of editing
strings.xmlto look like the given example, just add the new resource entries to the existing resource entries, so as not to delete the
@string/app_nameentry. In other words, following are reasonable contents for the
Note the entry for "hello" was generated automatically when the project was created. It is not actually used by the application, and can be safely excluded.
<!--?xml version="1.0" encoding="utf-8"?-->
<string name="hello">Hello World, HelloSpinner!</string>
<string name="app_name">Hello Spinner</string>
<string name="planet_prompt">Choose a planet</string>
For steps 4, 5, and 6, note the author(s)/editor(s) no doubt assumed readers would be able to provide the missing import statements, necessary for the code to compile. For these code changes, the following six items should be imported.
Step 5 contains a code error that needs to be corrected: it includes an extra closing parenthesis in the middle of the code. Correct this code
removing the extra ")" before the comma to then be
Toast.makeText(parent.getContext()), "The planet is " +
After implementing these corrections, users should be able to complete step 7, and successfully run the application.
Toast.makeText(parent.getContext(), "The planet is " +
Please don't hesitate to post any questions or problems you may still be having with the "Hello, Views > Spinner" tutorial below.