diff --git a/docs/html/_redirects.yaml b/docs/html/_redirects.yaml index 2169c8ed13be9..89672d7e8de10 100644 --- a/docs/html/_redirects.yaml +++ b/docs/html/_redirects.yaml @@ -21,6 +21,9 @@ redirects: - from: /sdk/compatibility-library.html to: /tools/support-library/index.html +- from: /training/basics/fragments/support-lib.html + to: /tools/support-library/setup.html + - from: /sdk/eclipse-adt.html to: /tools/sdk/eclipse-adt.html diff --git a/docs/html/sitemap.txt b/docs/html/sitemap.txt index 6291a3e2d932b..3a416f99ac611 100644 --- a/docs/html/sitemap.txt +++ b/docs/html/sitemap.txt @@ -362,7 +362,6 @@ http://developer.android.com/training/basics/supporting-devices/index.html http://developer.android.com/training/basics/supporting-devices/languages.html http://developer.android.com/training/basics/supporting-devices/screens.html http://developer.android.com/training/basics/supporting-devices/platforms.html -http://developer.android.com/training/basics/fragments/support-lib.html http://developer.android.com/training/basics/fragments/creating.html http://developer.android.com/training/basics/fragments/fragment-ui.html http://developer.android.com/training/basics/fragments/communicating.html diff --git a/docs/html/training/basics/fragments/creating.jd b/docs/html/training/basics/fragments/creating.jd index b5df4e1f7b56a..377adfce049a0 100644 --- a/docs/html/training/basics/fragments/creating.jd +++ b/docs/html/training/basics/fragments/creating.jd @@ -6,7 +6,7 @@ trainingnavtop=true
You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own input events, and which you can add or remove while the activity is running (sort of like a "sub activity" that you can reuse in different activities). This lesson shows how to -extend the {@link android.support.v4.app.Fragment} class using the Support Library so your app -remains compatible with devices running system versions as old as Android 1.6.
+extend the {@link android.support.v4.app.Fragment} class using the Support Library so your app +remains compatible with devices running system versions as low as Android 1.6. -Note: If you decide for other reasons that the minimum +
Note: If you decide that the minimum API level your app requires is 11 or higher, you don't need to use the Support Library and can instead use the framework's built in {@link android.app.Fragment} class and related APIs. Just be aware that this lesson is focused on using the APIs from the Support Library, which use a specific package signature and sometimes slightly different API names than the versions included in the platform.
+Before you begin this lesson, you must set up your Android project to use the Support Library. +If you have not used the Support Library before, set up your project to use the v4 +library by following the Support Library +Setup document. However, you can also include the action bar in your activities by instead using the +v7 appcompat library, which is compatible with Android 2.1 (API level 7) +and also includes the {@link android.support.v4.app.Fragment} APIs.
+To create a fragment, extend the {@link android.support.v4.app.Fragment} class, then override +
To create a fragment, extend the {@link android.support.v4.app.Fragment} class, then override key lifecycle methods to insert your app logic, similar to the way you would with an {@link android.app.Activity} class.
@@ -63,7 +72,7 @@ import android.view.ViewGroup; public class ArticleFragment extends Fragment { @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.article_view, container, false); @@ -82,7 +91,7 @@ href="{@docRoot}guide/components/fragments.html">Fragments developer guide.< -While fragments are reusable, modular UI components, each instance of a {@link android.support.v4.app.Fragment} class must be associated with a parent {@link @@ -98,7 +107,7 @@ regular {@link android.app.Activity}.
screen is considered "large" (specified by thelarge qualifier in the directory
name).
-res/layout-large/news_articles.xml:
res/layout-large/news_articles.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
@@ -120,11 +129,11 @@ name).
</LinearLayout>
-Tip: For more information about creating layouts for different +
Tip: For more about creating layouts for different screen sizes, read Supporting Different Screen Sizes.
-Here's how an activity applies this layout:
+Then apply the layout to your activity:
import android.os.Bundle;
@@ -139,6 +148,12 @@ public class MainActivity extends FragmentActivity {
}
+If you're using the v7 +appcompat library, your activity should instead extend {@link +android.support.v7.app.ActionBarActivity}, which is a subclass of {@link +android.support.v4.app.FragmentActivity} (for more information, +read Adding the Action Bar).
+Note: When you add a fragment to an activity layout by defining the fragment in the layout XML file, you cannot remove the fragment at runtime. If you plan diff --git a/docs/html/training/basics/fragments/index.jd b/docs/html/training/basics/fragments/index.jd index 1b82f2cd5dd08..987decf9a9816 100644 --- a/docs/html/training/basics/fragments/index.jd +++ b/docs/html/training/basics/fragments/index.jd @@ -57,9 +57,6 @@ devices running versions as old as Android 1.6.
Note: Several elements of this class require the Support Library APIs. -If you have not used the Support Library before, follow the lesson about Using the Support Library -to get your project set up.
+If you have not used the Support Library before, follow the instructions +in the Support Library Setup +document.