CHAPTER 4 Fragments ActionBar Menus. Explore how to build applications that use an ActionBar and Fragments Understand the Fragment lifecycle Learn to.

Slides:



Advertisements
Similar presentations
Android UserInterfaces Nasrullah Niazi. overView All user interface elements in an Android app are built using View and ViewGroup objects. A View is an.
Advertisements

CE881: Mobile and Social Application Programming Simon M. Lucas Menus and Dialogs.
AGENT TRAINING PowerPoint Basics. Goals: After today, you will be able to: Add new slides Add new slides Apply design templates Apply design templates.
Fragments: Introduction Fragments were introduced in Android 3.0 to support flexible and dynamic UI designs represent portions of an application’s user.
Unlocking Android Chapter 4.  Understanding activities and views  Exploring the Activity lifecycle  Working with resources  Defining the AndroidManifest.xml.
OOP Design Patterns Chapters Design Patterns The main idea behind design patterns is to extract the high level interactions between objects and.
 User Interface - Raeha Sandalwala.  Introduction to UI  Layouts  UI Controls  Menus and ‘Toasts’  Notifications  Other interesting UIs ◦ ListView.
© by Pearson Education, Inc. All Rights Reserved.
Android Fragments.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Exploring the Basics of Windows XP
Module 3 Productivity Programs Common Features and Commands Microsoft Office 2007.
Programming with Android: Android Fragments Luca Bedogni Marco Di Felice Dipartimento di Scienze dell’Informazione Università di Bologna.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 9: Customize! Navigating with a Master/Detail.
ANDROID UI – FRAGMENTS. Fragment  An activity is a container for views  When you have a larger screen device than a phone –like a tablet it can look.
Chapter 5: Investigate! Lists, Arrays, and Web Browsers.
Chapter 9: Customize! Navigating with Tabs on a Tablet App.
Tip Calculator App Building an Android App with Java © by Pearson Education, Inc. All Rights Reserved.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 5: Investigate! Android Lists, Arrays,
CHAPTER 9 Introducing Microsoft Office Learning Objectives Start Office programs and explore common elements Use the Ribbon Work with files Use.
CHAPTER 9 Introducing Microsoft Office Learning Objectives Start Office programs and explore common elements Use the Ribbon Work with files Use.
Introduction to Maya. Maya’s Layout User Interface Elements In Maya, you can tear off menus to create separate floating boxes that you can place anywhere.
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
INTRODUCTION TO ANDROID. Slide 2 Application Components An Android application is made of up one or more of the following components Activities We will.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
SpotOn Game App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Android – Fragments L. Grewe.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
Cosc 4730 Android Fragments. Fragments You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
Macromedia Flash 8 Revealed WORKING WITH SYMBOLS AND INTERACTIVITY.
Pearson Webcast Series
Positioning Objects with CSS and Tables
More UI Action Bar, Navigation, and Fragments
Building User Interfaces Basic Applications
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
Chapter 2 Building User Interfaces and Basic Applications.
New Features in Release 5.0 (August 1, 2005). 2 Release 5.0 New Features Redesigned Navigation Experience Header Bar Updates My Profile Link Added Logout.
CHAPTER 9 File Storage Shared Preferences SQLite.
Today We Will Review: Operating Systems (Windows) (week 3 & 4) Starting up MS Windows Desktop and its contents Functions of the desktop components Brain.
ANDROID LAYOUTS AND WIDGETS. Slide 2 Introduction Parts of the Android screen Sizing widgets and fonts Layouts and their characteristics Buttons, checkboxes.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Android Fragments. Slide 2 Lecture Overview Getting resources and configuration information Conceptualizing the Back Stack Introduction to fragments.
The Flag Quiz app tests your ability to correctly identify 10 flags from various countries and territories.
Chapter 5: Investigate! Lists, Arrays, and Web Browsers.
Fragments and Menus Chapter 4 1. Objectives Learn three different types of menus: options, context, and popup Learn to configure the ActionBar and Toolbar.
Menus. Menus are a common user interface component in many types of applications. The options menu is the primary collection of menu items for an activity.
Introduction to Event-Driven Programming
Activities, Fragments, and Events
Fragment ?.
Mobile Application Development BSCS-7 Lecture # 6
Mobile Applications (Android Programming)
Activities and Intents
Widgets & Fragments Kalin Kadiev Astea Solutions AD.
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
Politeknik Elektronika Negeri Surabaya
Mobile Application Development BSCS-7 Lecture # 11
Android – Fragments L. Grewe.
ANDROID UI – FRAGMENTS UNIT II.
Chap 7. Building Java Graphical User Interfaces
Graphical User Interfaces -- Introduction
Building User Interfaces Basic Applications
Android Topics Limited Resources and why we need to consider them.
Microsoft Windows 7 Basics
Activities and Fragments
Mobile Programmming Dr. Mohsin Ali Memon.
Presentation transcript:

CHAPTER 4 Fragments ActionBar Menus

Explore how to build applications that use an ActionBar and Fragments Understand the Fragment lifecycle Learn to configure the ActionBar Implement Fragments with Responsive Design Techniques Explore animation in Fragment Transactions Experiment with Fragments, ListViews, and ArrayAdapters

4.1 Fragmentation and Android Fragments There are many shapes and screen sizes and different performance characteristics Multiple versions of Android are being used This translates into a wider audience to build applications for When designing and coding layouts, there are several factors to consider, such as spacing, positioning, size, and the grouping of user interface controls Layouts must be compatible with many physical screens

A Fragment is modeled as a subdivision of an Activity Fragment is integrated into an Activity, and needs an Activity to run The advantage of building applications that use Fragments is their ability to easily present a consistently well- designed user interface Fragments are particularly helpful in adapting a user experience across a wide range of devices.

4.2 The Fragment Lifecycle Fragments are associated with an activity and can be created, added or removed while the activity is running Similar to an Activity, a Fragment has its own lifecycle, as well as its own user interface The Fragment’s lifecycle is connected to the activity that owns it Each fragment has its own callback methods in the standard Activity lifecycle.

Callbacks used in the lifecycle of a Fragment. onCreateView() – bring a fragment to resumed state, interacting with user onInflate() – called every time fragment is inflated onActivityCreated() – called when fragment’s activity has been created and this fragment’s view hierarchy is instantianted onAttach() – called after the fragment has been attached to an activity onDestroyView() – informs the fragment that its view is being destroyed so that it can clean up any associated resources. Called after onStop() and before onDestroy() onDetach() – called when fragment is no longer attached to its activity, after on Destroy(). This is the final call before the fragment object is released to garbage collector

4.3 Action Bar The action bar provides information and displays control elements to the user. In a basic configuration, the action bar displays the application icon and a title The title often identifies the running activity Users are given an indication of where they are and a consistent identity from which to recognize the application

Action bar features: Application Icon Action Items Action overflow

4.4 ActionBar Configurations Control elements that appear directly on the action bar as an icon and/or text are known as action buttons When an Activity starts, its associated layout is inflated on the screen and the action bar is populated with action buttons The activity's onCreateOptionsMenu() method is responsible for inflating a menu hierarchy from a specified XML resource file

4.4.1 Overflow on the Action Bar Narrow devices can often require the use of the overflow button When creating layouts on devices with a narrow screen, use ifRoom to request that an item appear in the action bar Allow the system to move elements into the overflow when there is not enough room

4.4.2 Adding an Action View An action view is simply a widget that appears in the action bar as a substitute for an action button An action view provides quick access to heavily used actions Consider a collapsible search view widget. A search action view can be added as an embedded search view widget in the action bar To declare an action view, the actionLayout or actionViewClass attribute can be added to an item to specify either a layout resource or a widget class

4.5 Responsive Design with Fragments Responsive design works across different screens sizes Responsive design techniques should also be applied to Android applications for solving interactive design and layout problems Responsive design is used for heavy data driven content. Adaptive design is primarily used for the re- arrangement of fixed user interface elements in an application

Responsive design revolves around a master/detail flow interface design pattern The user is provided with a list of items Upon selecting one of the items, additional information relating to that item is then presented to the user

This design concept is called responsive in the sense that list and detail panels of the app can change based on the width of the device On a large tablet-sized Android device, the screen is large enough to display both panels The master list can appear as a narrow vertical panel along the left hand edge of the screen while the remainder of the screen can display the detail panel This arrangement is referred to as two- pane mode.

Responsive design makes use of Fragments A user interface can be divided into multiple panes using Fragments and reused in more than one screen of an application, as shown in the following figure Fragments can be combined or separated on a device When building an application that follows a similar master/detail design pattern, the application often needs a set of Java and XML layout resource files

4.6 Animation in Fragment Transactions Transition animations can be applied directly to fragments that are entering and exiting a transaction The FragmentManager provides the structure that handles transactions between fragments A transaction refers to the sequence of steps that add, replace, or remove fragments. Operations performed by the FragmentManager will occur inside a transaction

4.7 ListViews and Dynamic Data A ListView is similar to a ScrollView A ScrollView is an extension of the FrameLayout, and is suitable for holding a single control element It provides the user with the scroll mechanism to reveal more content than can be displayed on the screen at once A LinearLayout, containing multiple View items, can be placed within a ScrollView

A ListView is a specialized control that is optimized for displaying long lists of items When the data content for the layout is dynamic or not pre-determined, it is possible to use a layout that subclasses an AdapterView to populate the layout with views at runtime

4.8 Handling Click Events in a ListView A ListView might be populated with items that need to respond to a click event You can respond to click events on an item in an AdapterView by implementing the AdapterView.OnItemClickListener interface The onItemClick () callback method will always be invoked when an item in the AdapterView has been clicked.