From 93dc642eaf48e3db58c4929df26283fbc5fd663f Mon Sep 17 00:00:00 2001
From: Scott Main The bitmap will be flattened into the parcel if this object is
* sent across processes, so it may end up using a lot of memory, and may be fairly slow.
The Android system image distributed in the SDK contains ARM machine code for diff --git a/docs/html/guide/developing/tools/emulator.jd b/docs/html/guide/developing/tools/emulator.jd index 5151ec14db47..09e41c3a17c2 100644 --- a/docs/html/guide/developing/tools/emulator.jd +++ b/docs/html/guide/developing/tools/emulator.jd @@ -516,7 +516,7 @@ the keys of your keyboard.
For example—to continue with the news application example—the application can embed two fragments in Activity A, when running on a tablet-sized device. However, on a -handset-sized screen, there's not be enough room for both fragments, so Activity A includes +handset-sized screen, there's not enough room for both fragments, so Activity A includes only the fragment for the list of articles, and when the user selects an article, it starts Activity B, which includes the second fragment to read the article. Thus, the application supports both tablets and handsets by reusing fragments in different combinations, as illustrated in diff --git a/docs/html/guide/topics/wireless/bluetooth.jd b/docs/html/guide/topics/wireless/bluetooth.jd index 76da08eebe4b..0567799565e2 100644 --- a/docs/html/guide/topics/wireless/bluetooth.jd +++ b/docs/html/guide/topics/wireless/bluetooth.jd @@ -249,12 +249,20 @@ if (!mBluetoothAdapter.isEnabled()) {
A dialog will appear requesting user permission to enable Bluetooth, as shown in Figure 1. If the user responds "Yes," the system will begin to enable Bluetooth and focus will return to your application once the process completes (or fails).
-If enabling Bluetooth succeeds, your Activity will receive the {@link + +
The {@code REQUEST_ENABLE_BT} constant passed to {@link
+android.app.Activity#startActivityForResult(Intent,int) startActivityForResult()} is a locally
+defined integer (which must be greater than 0), that the system passes back to you in your
+{@link
+android.app.Activity#onActivityResult(int,int,Intent) onActivityResult()} implementation as the
+requestCode parameter.
If enabling Bluetooth succeeds, your activity receives the {@link android.app.Activity#RESULT_OK} result code in the {@link android.app.Activity#onActivityResult(int,int,Intent) onActivityResult()} callback. If Bluetooth was not enabled -due to an error (or the user responded "No") then the result code will be {@link -android.app.Activity#RESULT_CANCELED}.
+due to an error (or the user responded "No") then the result code is {@link +android.app.Activity#RESULT_CANCELED}. @@ -431,11 +439,11 @@ startActivity(discoverableIntent);A dialog will be displayed, requesting user permission to make the device discoverable, as shown in Figure 2. If the user responds "Yes," then the device -will become discoverable for the specified amount of time. Your Activity will +will become discoverable for the specified amount of time. Your activity will then receive a call to the {@link android.app.Activity#onActivityResult(int,int,Intent) onActivityResult())} callback, with the result code equal to the duration that the device is discoverable. If the user responded "No" or if an error occurred, the result code will -be Activity.RESULT_CANCELLED.
+be {@link android.app.Activity#RESULT_CANCELED}.Note: If Bluetooth has not been enabled on the device, then enabling device discoverability will automatically enable Bluetooth.
@@ -568,7 +576,7 @@ socket.The {@link android.bluetooth.BluetoothServerSocket#accept()} call should not -be executed in the main Activity UI thread because it is a blocking call and +be executed in the main activity UI thread because it is a blocking call and will prevent any other interaction with the application. It usually makes sense to do all work with a {@link android.bluetooth.BluetoothServerSocket} or {@link android.bluetooth.BluetoothSocket} in a new @@ -696,7 +704,7 @@ android.bluetooth.BluetoothSocket#connect()} method times out (after about 12 seconds), then it will throw an exception.
Because {@link android.bluetooth.BluetoothSocket#connect()} is a blocking call, this connection -procedure should always be performed in a thread separate from the main Activity +procedure should always be performed in a thread separate from the main activity thread.
Note: You should always ensure that the device is not performing device discovery when you call {@link @@ -838,7 +846,7 @@ private class ConnectedThread extends Thread { try { // Read from the InputStream bytes = mmInStream.read(buffer); - // Send the obtained bytes to the UI Activity + // Send the obtained bytes to the UI activity mHandler.obtainMessage(MESSAGE_READ, bytes, -1, buffer) .sendToTarget(); } catch (IOException e) { @@ -847,14 +855,14 @@ private class ConnectedThread extends Thread { } } - /* Call this from the main Activity to send data to the remote device */ + /* Call this from the main activity to send data to the remote device */ public void write(byte[] bytes) { try { mmOutStream.write(bytes); } catch (IOException e) { } } - /* Call this from the main Activity to shutdown the connection */ + /* Call this from the main activity to shutdown the connection */ public void cancel() { try { mmSocket.close(); @@ -866,12 +874,12 @@ private class ConnectedThread extends Thread {
The constructor acquires the necessary streams and once executed, the thread will wait for data to come through the InputStream. When {@link java.io.InputStream#read(byte[])} returns with -bytes from the stream, the data is sent to the main Activity using a member +bytes from the stream, the data is sent to the main activity using a member Handler from the parent class. Then it goes back and waits for more bytes from the stream.
Sending outgoing data is as simple as calling the thread's
-write() method from the main Activity and passing in the bytes to
+write() method from the main activity and passing in the bytes to
be sent. This method then simply calls {@link
java.io.OutputStream#write(byte[])} to send the data to the remote device.
menu.add() like so:
-public void onCreateContextMenu(Menu menu, View v, ContextMenuInfo menuInfo) {
+public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.add(0, DELETE_ID, 0, R.string.menu_delete);
}
diff --git a/docs/html/resources/tutorials/views/hello-formstuff.jd b/docs/html/resources/tutorials/views/hello-formstuff.jd
index b9f6c16dd749..1ddd1df7fe84 100644
--- a/docs/html/resources/tutorials/views/hello-formstuff.jd
+++ b/docs/html/resources/tutorials/views/hello-formstuff.jd
@@ -91,31 +91,30 @@ android.widget.Button} element:
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
- android:background="@drawable/android_button" />
+ android:background="@drawable/android_button"
+ android:onClick="onButtonClicked"/>
The android:background attribute specifies the drawable resource to use for the
button background (which, when saved at res/drawable/android.xml, is
referenced as @drawable/android). This replaces the normal background image
-used for buttons throughout the system. In order for the drawable to change its image based on
-the button state, the image must be applied to the background.
The attribute android:onClick specifies the name of a method in your activity
+that the system should call when the user clicks the button. You'll create that method next.
-final Button button = (Button) findViewById(R.id.button);
-button.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- // Perform action on clicks
- Toast.makeText(HelloFormStuff.this, "Beep Bop", Toast.LENGTH_SHORT).show();
- }
-});
+public void onButtonClicked(View v) {
+ // Do something when the button is clicked
+ Toast.makeText(HelloFormStuff.this, "Button clicked", Toast.LENGTH_SHORT).show();
+}
-This captures the {@link android.widget.Button} from the layout, then adds an {@link -android.view.View.OnClickListener}. The {@link android.view.View.OnClickListener} -must implement the {@link android.view.View.OnClickListener#onClick(View)} callback method, which -defines the action to be made when the button is clicked. In this example, a -{@link android.widget.Toast} message will be displayed.
+When you specify this kind of method, which is used in your layout file with the {@code
+android:onClick} attribute, the method must be public, have a void return
+value, and accept a single {@code android.view.View} parameter. When the system calls this method,
+it passes the {@code android.view.View} that was clicked.
The attribute android:onClick specifies the name of a method in your activity
+that the system should call when the user clicks the check box. You'll create that method next.
-final CheckBox checkbox = (CheckBox) findViewById(R.id.checkbox);
-checkbox.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- // Perform action on clicks, depending on whether it's now checked
- if (((CheckBox) v).isChecked()) {
- Toast.makeText(HelloFormStuff.this, "Selected", Toast.LENGTH_SHORT).show();
- } else {
- Toast.makeText(HelloFormStuff.this, "Not selected", Toast.LENGTH_SHORT).show();
- }
+public void onCheckboxClicked(View v) {
+ // Perform action on clicks, depending on whether it's now checked
+ if (((CheckBox) v).isChecked()) {
+ Toast.makeText(HelloFormStuff.this, "Selected", Toast.LENGTH_SHORT).show();
+ } else {
+ Toast.makeText(HelloFormStuff.this, "Not selected", Toast.LENGTH_SHORT).show();
}
-});
+}
-This captures the {@link android.widget.CheckBox} element from the layout, then adds an {@link -android.view.View.OnClickListener}. The {@link android.view.View.OnClickListener} must implement the -{@link android.view.View.OnClickListener#onClick(View)} callback method, which -defines the action to be made when the checkbox is clicked. When clicked, {@link -android.widget.CompoundButton#isChecked()} is called to check the new state of the check box. If it -has been checked, then a {@link android.widget.Toast} displays the message "Selected", otherwise it -displays "Not selected". Note that the {@link android.view.View} object that is passed in the {@link -android.view.View.OnClickListener#onClick(View)} callback must be cast to a {@link -android.widget.CheckBox} because the {@link android.widget.CompoundButton#isChecked()} method is -not defined by the parent {@link android.view.View} class. The {@link android.widget.CheckBox} + +
When you specify this kind of method, which is used in your layout file with the {@code
+android:onClick}
+attribute, the method must be public, have a void return value, and
+accept a single {@code android.view.View} parameter. When the system calls this method, it
+passes the {@code android.view.View} that was clicked. In this example, the {@code
+android.view.View} is cast to a {@link android.widget.CheckBox} to determine whether the widget
+has been checked or unchecked. The {@link android.widget.CheckBox} widget
handles its own state changes, so you only need to query the current state.
It's important that the {@link android.widget.RadioButton}s are grouped together by the {@link android.widget.RadioGroup} element so that no more than one can be selected at a time. This logic is automatically handled by the Android system. When one {@link android.widget.RadioButton} within a group is selected, all others are automatically deselected.
+The attribute android:onClick specifies the name of a method in your activity
+that the system should call when the user clicks the radio button. You'll create that method
+next.
HelloFormStuff Activity:
-
-private 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();
- }
-};
-
-First, the {@link android.view.View} that is passed to the {@link -android.view.View.OnClickListener#onClick(View)} method is cast into a RadioButton. Then a -{@link android.widget.Toast} message displays the selected radio button's text.
-
- final RadioButton radio_red = (RadioButton) findViewById(R.id.radio_red);
- final RadioButton radio_blue = (RadioButton) findViewById(R.id.radio_blue);
- radio_red.setOnClickListener(radio_listener);
- radio_blue.setOnClickListener(radio_listener);
+public void onRadioButtonClicked(View v) {
+ // Perform action on clicks
+ RadioButton rb = (RadioButton) v;
+ Toast.makeText(HelloFormStuff.this, rb.getText(), Toast.LENGTH_SHORT).show();
+}
-This captures each of the {@link android.widget.RadioButton}s from the layout and adds the -newly-created {@link android.view.View.OnClickListener} to each.
+ +When you specify this kind of method, which is used in your layout file with the {@code
+android:onClick}
+attribute, the method must be public, have a void return value, and
+accept a single {@code android.view.View} parameter. When the system calls this method, it
+passes the {@code android.view.View} that was clicked.
Because each {@link android.widget.RadioButton} widget is grouped into a {@link +android.widget.RadioGroup}, each widget handles its own state changes when a new button is +selected.
+The attributes android:textOn and android:textOff specify the text
for the button when the button has been toggled on or off. The default values are "ON" and
"OFF".
The attribute android:onClick specifies the name of a method in your activity
+that the system should call when the user clicks the button. You'll create that method next.
-final ToggleButton togglebutton = (ToggleButton) findViewById(R.id.togglebutton);
-togglebutton.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- // Perform action on clicks
- if (togglebutton.isChecked()) {
- Toast.makeText(HelloFormStuff.this, "Checked", Toast.LENGTH_SHORT).show();
- } else {
- Toast.makeText(HelloFormStuff.this, "Not checked", Toast.LENGTH_SHORT).show();
- }
+public void onToggleClicked(View v) {
+ // Perform action on clicks
+ if (((ToggleButton) v).isChecked()) {
+ Toast.makeText(HelloFormStuff.this, "Toggle on", Toast.LENGTH_SHORT).show();
+ } else {
+ Toast.makeText(HelloFormStuff.this, "Toggle off", Toast.LENGTH_SHORT).show();
}
-});
+}
-This captures the {@link android.widget.ToggleButton} element from the layout, then adds an -{@link android.view.View.OnClickListener}. The {@link android.view.View.OnClickListener} must -implement the {@link android.view.View.OnClickListener#onClick(View)} callback method, which -defines the action to perform when the button is clicked. In this example, the callback + +
When you specify this kind of method, which is used in your layout file with the {@code
+android:onClick}
+attribute, the method must be public, have a void return value, and
+accept a single {@code android.view.View} parameter. When the system calls this method, it
+passes the {@code android.view.View} that was clicked.
In this example, the callback method checks the new state of the button, then shows a {@link android.widget.Toast} message that indicates the current state.
diff --git a/docs/html/resources/tutorials/views/hello-mapview.jd b/docs/html/resources/tutorials/views/hello-mapview.jd index ac5e826e41c2..7a0bedf5dd69 100644 --- a/docs/html/resources/tutorials/views/hello-mapview.jd +++ b/docs/html/resources/tutorials/views/hello-mapview.jd @@ -208,7 +208,7 @@ public int size() { new class constructor:
public HelloItemizedOverlay(Drawable defaultMarker, Context context) {
- super(defaultMarker);
+ super(boundCenterBottom(defaultMarker));
mContext = context;
}
--
cgit v1.2.3-59-g8ed1b