diff --git a/docs/html/images/screens_support/avds-config.png b/docs/html/images/screens_support/avds-config.png index 97bd5f6d0b4ff..e60944722c329 100644 Binary files a/docs/html/images/screens_support/avds-config.png and b/docs/html/images/screens_support/avds-config.png differ diff --git a/docs/html/images/training/firstapp/adt-firstapp-setup.png b/docs/html/images/training/firstapp/adt-firstapp-setup.png index bf95285969274..05e147dfb40d3 100644 Binary files a/docs/html/images/training/firstapp/adt-firstapp-setup.png and b/docs/html/images/training/firstapp/adt-firstapp-setup.png differ diff --git a/docs/html/images/training/firstapp/adt-new-activity.png b/docs/html/images/training/firstapp/adt-new-activity.png index c396793655c7b..2c32dcc8055a4 100644 Binary files a/docs/html/images/training/firstapp/adt-new-activity.png and b/docs/html/images/training/firstapp/adt-new-activity.png differ diff --git a/docs/html/images/training/firstapp/edittext_gravity.png b/docs/html/images/training/firstapp/edittext_gravity.png index f78e67671c11a..bc4f7ee8f4390 100644 Binary files a/docs/html/images/training/firstapp/edittext_gravity.png and b/docs/html/images/training/firstapp/edittext_gravity.png differ diff --git a/docs/html/images/training/firstapp/edittext_wrap.png b/docs/html/images/training/firstapp/edittext_wrap.png index 156776d776994..fe56731a38c91 100644 Binary files a/docs/html/images/training/firstapp/edittext_wrap.png and b/docs/html/images/training/firstapp/edittext_wrap.png differ diff --git a/docs/html/images/training/firstapp/firstapp.png b/docs/html/images/training/firstapp/firstapp.png index d69cd2008fd5a..581e00048ce7c 100644 Binary files a/docs/html/images/training/firstapp/firstapp.png and b/docs/html/images/training/firstapp/firstapp.png differ diff --git a/docs/html/training/basics/firstapp/building-ui.jd b/docs/html/training/basics/firstapp/building-ui.jd index 2615bee81feb3..179b3ac445a24 100644 --- a/docs/html/training/basics/firstapp/building-ui.jd +++ b/docs/html/training/basics/firstapp/building-ui.jd @@ -75,16 +75,16 @@ content of the text field to another activity.
Open the activity_main.xml file from the res/layout/
+
Open the fragment_main.xml file from the res/layout/
directory.
Note: In Eclipse, when you open a layout file, you’re first shown the Graphical Layout editor. This is an editor that helps you build layouts using WYSIWYG tools. For this -lesson, you’re going to work directly with the XML, so click the activity_main.xml tab at +lesson, you’re going to work directly with the XML, so click the fragment_main.xml tab at the bottom of the screen to open the XML editor.
The BlankActivity template you chose when you created this project includes the
-activity_main.xml file with a {@link
+fragment_main.xml file with a {@link
android.widget.RelativeLayout} root view and a {@link android.widget.TextView} child view.
First, delete the {@link android.widget.TextView <TextView>} element and change the {@link
@@ -95,7 +95,6 @@ android:orientation} attribute and set it to "horizontal".
The result looks like this:
-<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
diff --git a/docs/html/training/basics/firstapp/creating-project.jd b/docs/html/training/basics/firstapp/creating-project.jd
index 9516e378afd47..50485dbe8c446 100644
--- a/docs/html/training/basics/firstapp/creating-project.jd
+++ b/docs/html/training/basics/firstapp/creating-project.jd
@@ -120,8 +120,8 @@ devices.
Finish.
-Your Android project is now set up with some default files and you’re ready to begin
-building the app. Continue to the next lesson.
+Your Android project is now a basic "Hello World" app that contains some default files.
+To run the app, continue to the next lesson.
@@ -155,8 +155,8 @@ and replace
projects.
-Your Android project is now set up with several default configurations and you’re ready to begin
-building the app. Continue to the next lesson.
+Your Android project is now a basic "Hello World" app that contains some default files.
+To run the app, continue to the next lesson.
Tip: Add the platform-tools/ as well as the
tools/ directory to your PATH environment variable.
diff --git a/docs/html/training/basics/firstapp/running-app.jd b/docs/html/training/basics/firstapp/running-app.jd
index 999d399f3d50a..23cedba1e8b90 100644
--- a/docs/html/training/basics/firstapp/running-app.jd
+++ b/docs/html/training/basics/firstapp/running-app.jd
@@ -62,7 +62,7 @@ href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code andro
attributes. For your first app, it should look like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" ... >
- <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />
+ <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" />
...
</manifest>
diff --git a/docs/html/training/basics/firstapp/starting-activity.jd b/docs/html/training/basics/firstapp/starting-activity.jd
index 712eabc424c8a..9aa25a375707e 100644
--- a/docs/html/training/basics/firstapp/starting-activity.jd
+++ b/docs/html/training/basics/firstapp/starting-activity.jd
@@ -45,7 +45,7 @@ starts a new activity when the user clicks the Send button.
Respond to the Send Button
-To respond to the button's on-click event, open the activity_main.xml
+
To respond to the button's on-click event, open the fragment_main.xml
layout file and add the {@code android:onClick}
attribute to the {@link android.widget.Button <Button>} element:
@@ -73,14 +73,6 @@ public void sendMessage(View view) {
}
-This requires that you import the {@link android.view.View} class:
--import android.view.View; -- -
Tip: In Eclipse, press Ctrl + Shift + O to import missing classes -(Cmd + Shift + O on Mac).
-In order for the system to match this method to the method name given to {@code android:onClick}, the signature must be exactly as shown. Specifically, the method must:
@@ -111,6 +103,14 @@ an activity called {@code DisplayMessageActivity}: Intent intent = new Intent(this, DisplayMessageActivity.class); +This requires that you import the {@link android.content.Intent} class:
++import android.content.Intent; ++ +
Tip: In Eclipse, press Ctrl + Shift + O to import missing classes +(Cmd + Shift + O on Mac).
+The constructor used here takes two parameters:
Note:
-You now need import statements for android.content.Intent
-and android.widget.EditText. You'll define the EXTRA_MESSAGE
-constant in a moment.
android.widget.EditText.
+You'll define the EXTRA_MESSAGE constant in a moment.
An {@link android.content.Intent} can carry a collection of various data types as key-value pairs called extras. The {@link android.content.Intent#putExtra putExtra()} method takes the @@ -165,7 +164,7 @@ public constant. So add the {@code EXTRA_MESSAGE} definition to the top of the { MainActivity} class:
-public class MainActivity extends Activity {
+public class MainActivity extends ActionBarActivity {
public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
...
}
@@ -223,6 +222,7 @@ work.
PlaceholderFragment class that extends
+{@link android.app.Fragment}. You will not need this class in the final version of this
+activity.Because the {@link android.app.ActionBar} APIs are available only on {@link -android.os.Build.VERSION_CODES#HONEYCOMB} (API level 11) and higher, you must add a condition -around the {@link android.app.Activity#getActionBar()} method to check the current platform version. -Additionally, you must add the {@code @SuppressLint("NewApi")} tag to the -{@link android.app.Activity#onCreate onCreate()} method to avoid lint errors.
+Fragments decompose application functionality and UI into reusable modules. For more +information on fragments, see the Fragments +API Guide. The final version of this activity does not use fragments.
The {@code DisplayMessageActivity} class should now look like this:
-public class DisplayMessageActivity extends Activity {
+public class DisplayMessageActivity extends ActionBarActivity {
- @SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_message);
- // Make sure we're running on Honeycomb or higher to use ActionBar APIs
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
- // Show the Up button in the action bar.
- getActionBar().setDisplayHomeAsUpEnabled(true);
+ if (savedInstanceState == null) {
+ getSupportFragmentManager().beginTransaction()
+ .add(R.id.container, new PlaceholderFragment()).commit();
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- NavUtils.navigateUpFromSameTask(this);
+ // Handle action bar item clicks here. The action bar will
+ // automatically handle clicks on the Home/Up button, so long
+ // as you specify a parent activity in AndroidManifest.xml.
+ int id = item.getItemId();
+ if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
+
+ /**
+ * A placeholder fragment containing a simple view.
+ */
+ public static class PlaceholderFragment extends Fragment {
+
+ public PlaceholderFragment() { }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View rootView = inflater.inflate(R.layout.fragment_display_message,
+ container, false);
+ return rootView;
+ }
+ }
}
@@ -422,7 +438,7 @@ public void onCreate(Bundle savedInstanceState) {
Figure 2. Both activities in the final app, running -on Android 4.0. +on Android 4.4.
That's it, you've built your first Android app!