html5-img
1 / 11

Activity

Applications were originally built on the Activity class.

una
Télécharger la présentation

Activity

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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). “ Activity Activity Activity *AD signifies a direct quote from Android Documentation. Activity

  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.” Intent mapIntent= new Intent(this, MapActivity.class); startActivity(mapIntent); Intent Intent Activity Activity Activity Activity

  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 Fragment Fragment Fragment

  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). ” FragmentTransactionft = getFragmentManager().beginTransaction(); ft.replace(android.R.id.content, mMapFragment).commit(); Fragment Activity Fragment Fragment Fragment

  5. Intent Intent Fragment Fragment Activity Another Activity Yet Another Activity An Activity with a collection of Fragments can use an Intent to launch another Activity and associated Fragments. Fragment Fragment Fragment Fragment Fragment Fragment

  6. Reusable Fragments: • Created in the Activity • Known by the Activity • Exchange of information between Fragments is accomplished by routing information through the Activity Fragment Activity Fragment Fragment Fragment

  7. Image courtesy of dream designs at FreeDigitalPhotos.net

  8. Application Icon/Application Name Fragment Content Action Bar

  9. Activity Fragments

  10. Only one Fragment is shown at a time. Typical Fragment Operations: add, remove, show , hide and replace

  11. Layout File <menu xmlns:android="http://schemas.android.com/apk/res/android" > <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" /> </menu> Action Bar Resource File

More Related