diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 14:04:24 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 14:04:24 -0800 |
commit | 076357b8567458d4b6dfdcf839ef751634cd2bfb (patch) | |
tree | efbb2fd6f1dc67d2d606382fc3b82983e7cb2e1f /docs/html/guide/tutorials | |
parent | 3dec7d563a2f3e1eb967ce2054a00b6620e3558c (diff) | |
download | frameworks_base-076357b8567458d4b6dfdcf839ef751634cd2bfb.zip frameworks_base-076357b8567458d4b6dfdcf839ef751634cd2bfb.tar.gz frameworks_base-076357b8567458d4b6dfdcf839ef751634cd2bfb.tar.bz2 |
auto import from //depot/cupcake/@132589
Diffstat (limited to 'docs/html/guide/tutorials')
4 files changed, 26 insertions, 31 deletions
diff --git a/docs/html/guide/tutorials/views/hello-autocomplete.jd b/docs/html/guide/tutorials/views/hello-autocomplete.jd index fba1ad8..de3ba29 100644 --- a/docs/html/guide/tutorials/views/hello-autocomplete.jd +++ b/docs/html/guide/tutorials/views/hello-autocomplete.jd @@ -40,7 +40,7 @@ protected void onCreate(Bundle savedInstanceState) { AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.edit); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, - android.R.layout.simple_dropdown_item_1line, COUNTRIES); + android.R.layout.simple_dropdown_item_1line, R.array.planets); textView.setAdapter(adapter); } </pre> diff --git a/docs/html/guide/tutorials/views/hello-formstuff.jd b/docs/html/guide/tutorials/views/hello-formstuff.jd index da4289c..f858ce3 100644 --- a/docs/html/guide/tutorials/views/hello-formstuff.jd +++ b/docs/html/guide/tutorials/views/hello-formstuff.jd @@ -32,7 +32,7 @@ We'll make it display a message when pressed.</p> <ol> <li><img src="images/android.png" align="right"/> Drag the Android image on the right (or your own image) into the - res/drawable/ directory of your project. + res/drawables/ directory of your project. We'll use this for the button.</li> <li>Open the layout file and, inside the LinearLayout, add the {@link android.widget.ImageButton} element: <pre> @@ -43,7 +43,7 @@ We'll make it display a message when pressed.</p> android:src="@drawable/android" /> </pre> <p>The source of the button - is from the res/drawable/ directory, where we've placed the android.png.</p> + is from the res/drawables/ directory, where we've placed the android.png.</p> <p class="note"><strong>Tip:</strong> You can also reference some of the many built-in images from the Android {@link android.R.drawable} resources, like <code>ic_media_play</code>, for a "play" button image. To do so, change the source @@ -52,7 +52,7 @@ We'll make it display a message when pressed.</p> <li>To make the button to actually do something, add the following code at the end of the <code>onCreate()</code> method: <pre> -final ImageButton button = (ImageButton) findViewById(R.id.android_button); +ImageButton button = (ImageButton) findViewById(R.id.android_button); button.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Perform action on clicks @@ -84,12 +84,12 @@ defines the action to be made when the button is clicked. Here, we show a <li>To do something with the text that the user enters, add the following code to the end of the <code>onCreate()</code> method: <pre> -final EditText edittext = (EditText) findViewById(R.id.edittext); +EditText edittext = (EditText) findViewById(R.id.edittext); edittext.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { // Perform action on key press - Toast.makeText(HelloFormStuff.this, edittext.getText(), Toast.LENGTH_SHORT).show(); + Toast.makeText(HelloImageButton.this, edittext.getText(), Toast.LENGTH_SHORT).show(); return true; } return false; @@ -127,9 +127,9 @@ checkbox.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Perform action on clicks if (checkbox.isChecked()) { - Toast.makeText(HelloFormStuff.this, "Selected", Toast.LENGTH_SHORT).show(); + Toast.makeText(HelloImageButton.this, "Selected", Toast.LENGTH_SHORT).show(); } else { - Toast.makeText(HelloFormStuff.this, "Not selected", Toast.LENGTH_SHORT).show(); + Toast.makeText(HelloImageButton.this, "Not selected", Toast.LENGTH_SHORT).show(); } } }); @@ -183,7 +183,7 @@ OnClickListener radio_listener = new OnClickListener() { public void onClick(View v) { // Perform action on clicks RadioButton rb = (RadioButton) v; - Toast.makeText(HelloFormStuff.this, rb.getText(), Toast.LENGTH_SHORT).show(); + Toast.makeText(HelloImageButton.this, rb.getText(), Toast.LENGTH_SHORT).show(); } }; </pre> @@ -225,9 +225,9 @@ togglebutton.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Perform action on clicks if (togglebutton.isChecked()) { - Toast.makeText(HelloFormStuff.this, "ON", Toast.LENGTH_SHORT).show(); + Toast.makeText(HelloImageButton.this, "ON", Toast.LENGTH_SHORT).show(); } else { - Toast.makeText(HelloFormStuff.this, "OFF", Toast.LENGTH_SHORT).show(); + Toast.makeText(HelloImageButton.this, "OFF", Toast.LENGTH_SHORT).show(); } } }); diff --git a/docs/html/guide/tutorials/views/hello-gridview.jd b/docs/html/guide/tutorials/views/hello-gridview.jd index ffb6c93..623a03d 100644 --- a/docs/html/guide/tutorials/views/hello-gridview.jd +++ b/docs/html/guide/tutorials/views/hello-gridview.jd @@ -25,7 +25,6 @@ are acquired from a {@link android.widget.ListAdapter}.</p> android:stretchMode="columnWidth" android:gravity="center" /> -</pre> </li> <li>Open the HelloGridView Java file. Insert the following for the <code>onCreate()</code> method: <pre> diff --git a/docs/html/guide/tutorials/views/hello-mapview.jd b/docs/html/guide/tutorials/views/hello-mapview.jd index 976b8ab..b0f59de 100644 --- a/docs/html/guide/tutorials/views/hello-mapview.jd +++ b/docs/html/guide/tutorials/views/hello-mapview.jd @@ -16,13 +16,8 @@ First, we'll create a simple Activity that can view and navigate a map. Then we <pre><uses-library android:name="com.google.android.maps" /></pre> </li> - <li>We also need access to the internet in order to retrieve the Google Maps tiles, - so the application must request the {@link android.Manifest.permission#INTERNET INTERNET} permissions. - In the manifest file, add the following as a child of the <code><manifest></code> element: - <pre><uses-permission android:name="android.permission.INTERNET" /></pre> - </li> - <li>Now open the main layout file for your project. Define a layout with a com.google.android.maps.MapView - inside a android.widget.RelativeLayout: + + <li>Open the layout file. Define the layout with a MapView inside a RelativeLayout: <pre> <?xml version="1.0" encoding="utf-8"?> @@ -37,21 +32,22 @@ First, we'll create a simple Activity that can view and navigate a map. Then we android:layout_width="fill_parent" android:layout_height="fill_parent" android:clickable="true" - android:apiKey="<em>Your Maps API Key</em>" + android:apiKey="INSERT YOUR KEY HERE" /> -</RelativeLayout> +<RelativeLayout> </pre> - <p>The <code>clickable</code> attribute defines whether you want to allow user-interaction with the map. - In this case, we set it "true" so that the user can navigate.</p> - - <p>The <code>apiKey</code> attribute holds the Google Maps API Key that proves your application and signer - certificate has been registered with the Google Maps service. Because MapView uses Google Maps data, this key is required - in order to receive the map data, even while you are developing. Registration is free and it only takes a couple - minutes to register your certificate and receive a Maps API Key. For instructions on getting a key, read - <a href="{@docRoot}guide/topics/location/geo/mapkey.html">Obtaining a Maps API Key</a>. - (For the purpose of this tutorial, you should register with the fingerprint of the SDK debug certificate.) - Once you've acquired the Maps API Key, insert it for the <code>apiKey</code> value.</p></li> + <p>Setting <code>clickable</code> is important. Otherwise, the map does not allow any user interaction.</p> + + <p>The <code>android:apiKey</code> must contain an authentic Android Maps API key. + The API key is generated using the MD5 fingerprint of your application certificate. For the purposes of + this exercise, you should use the fingerprint of your debug certificate (which cannot be used to release + your application for Android devices, but will work while developing). See how to + <a href="{@docRoot}guide/topics/location/geo/mapkey.html#getdebugfingerprint">generate a fingerprint from your + debug certificate</a>, then <a href="http://code.google.com/android/maps-api-signup.html">register the + certificate</a> to retieve an API key. + Insert the API key as the value of the <code>apiKey</code> attribute. If you do not insert a valid + Maps API key, the application will still run, but no map tiles will load.</p></li> <li>Now open the HelloMapView.java file. For this Activity, we're going to extend the special sub-class of Activity called MapActivity, so change the class declaration to extend |