Download presentation
Presentation is loading. Please wait.
Published byRocco Eliot Modified over 9 years ago
1
Activity Applications were originally built on the Activity class. AD * : “An activity is a single, focused thing that the user can do. Almost all activities interact with the user, so the Activity class takes care of creating a window for you in which you can place your UI with setContentView(View). “setContentView(View) * AD signifies a direct quote from Android Documentation.
2
AD: “An intent is an abstract description of an operation to be performed…Its most significant use is in the launching of activities, where it can be thought of as the glue between activities.” Activity Intent Intent mapIntent = new Intent(this, MapActivity.class); startActivity(mapIntent); Intent mapIntent = new Intent(this, MapActivity.class); startActivity(mapIntent);
3
AD: “Android introduced fragments in Android 3.0 (API level 11), primarily to support more dynamic and flexible UI designs on large screens, such as tablets. Because a tablet's screen is much larger than that of a handset, there's more room to combine and interchange UI components. Fragments allow such designs without the need for you to manage complex changes to the view hierarchy. By dividing the layout of an activity into fragments, you become able to modify the activity's appearance at runtime and preserve those changes in a back stack that's managed by the activity.” Fragment Activity
4
AD: “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). ” Fragment Activity FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(android.R.id.content, mMapFragment).commit(); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(android.R.id.content, mMapFragment).commit();
5
Fragment Activity Fragment Another Activity Another Activity Yet Another Activity Yet Another Activity Intent An Activity with a collection of Fragments can use an Intent to launch another Activity and associated Fragments. An Activity with a collection of Fragments can use an Intent to launch another Activity and associated Fragments. Intent
6
Fragment Activity Reusable Fragments: Created in the Activity Known by the Activity Exchange of information between Fragments is accomplished by routing information through the Activity
7
Image courtesy of dream designs at FreeDigitalPhotos.netFreeDigitalPhotos.net
8
Application Icon/Application Name Action Bar Fragment Content
9
Fragments Activity
10
Only one Fragment is shown at a time. Typical Fragment Operations: add, remove, show, hide and replace
11
<item android:id="@+id/information_activity" android:orderInCategory="99" android:showAsAction="always" android:icon="@drawable/lt_action_about" android:title="@string/information_view" /> <item android:id="@+id/map_activity" android:orderInCategory="100" android:showAsAction="always" android:icon="@drawable/lt_location_map" android:title="@string/map_view"/> <item android:id="@+id/forest_description_activity" android:orderInCategory="101" android:showAsAction="always" android:icon="@drawable/lt_collections_view_as_list" android:title="@string/picture_view" /> <item android:id="@+id/pix_activity" android:orderInCategory="102" android:showAsAction="always" android:icon="@drawable/lt_content_picture" android:title="@string/pix" /> Resource File Layout File Action Bar
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.