Fragments. Lecture 10

Size: px
Start display at page:

Download "Fragments. Lecture 10"

Transcription

1 Fragments Lecture 10

2 Situa2onal layouts Your app can use different layouts in different situa2ons Different device type (tablet vs. phone vs. watch) Different screen size Different orienta2on (portrait vs. landscape) Different country or locale (language, etc.)

3 Situa2on- specific folders Your app will look for resource folder names with suffixes: Screen density (e.g. drawable- hdpi) xhdpi: 2.0 (twice as many pixels/dots per inch) hdpi:1.5 mdpi: 1.0 (baseline) idpi: 0.75 Screen size (e.g. layout- large) Small, normal, large, xlarge Orienta2on (e.g. layout- land) Portrait, landscape

4 Portrait vs. Landscape Layout To create a different layout in landscape mode Create a folder in your project called res/layout- land Place another copy of your ac2vity s layout XML file there Modify it as needed to represent the differences

5 Problem: Redundant Layouts With situa2onal layout you begin to encounter redundancy The layout in one case (e.g. portrait or medium) is very similar to the layout in another case (e.g. landscape or large) You don t want to represent the same XML or Java code mul2ple 2mes or in mul2ple places

6 Situa2onal Layout You some2mes want your code to behave situa2onally In portrait mode, clicking a bu[on should launch a new ac2vity In landscape mode, clicking a bu[on, should launch a new view

7 Fragments A reusable segment of Android UI that can appear in an ac2vity Can help handle different devices and screen sizes Can reuse a common fragment across mul2ple ac2vi2es First added in Android 3.0

8 Fragments

9 Crea2ng a fragment In Android studio, right- click app, click: New - > Fragment - > Fragment(blank) Un- check boxes about Include_methods Now create layout XML and Java event code as in an Ac2vity

10 Using Fragments in ac2vity XML Ac2vity layout XML can include fragments <! ac2vity_name,xml - - > <LinearLayout > <fragment android:name= ClassName1 /> <fragment android:name= ClassName2 /> </LinearLayout>

11 Fragment Life Cycle Fragments have a similar life cycle and events as ac2vi2es Important methods: ona[ach to glue fragment to its surrounding ac2vity oncreate when fragment is loading oncreateview method that must return fragment s root UI view onac2vitycreated method that indicates the enclosing ac2vity is ready onpause when fragment is being lel/exited ondetach just as fragment is being deleted

12

13 Fragment template public class Name extends Fragment public View oncreateview(layoutinflater inflater, ViewGroup vg, Bundle bundle) { //load the GUI layout from the XML return inflater.inflate(r.layout.id,vg,false); public void onac2vitycreated(bundle savedstate) { super.onac2vitycreated(savedstate); // any other GUI ini2aliza2on needed // any other code (e.g. event handling)

14 Fragment vs. ac2vity Fragment code is similar to ac2vity code, with a few changes: Many ac2vity methods aren t present in the fragment, but you can call getac2vity to access the ac2vity the fragment is inside of Bu[on b = (Bu[on) findviewbyid (R.id.but); Bu[on b = (Bu[on) getac2vity().findviewbyid(r.id.but); Some2mes also use getview to refer to the ac2vity s layout Event handlers cannot be a[ached in the XML any more :- < Must be a[ached in Java code instead Passing informa2on to a fragment (via Intent/Bundle) is trickier The fragment must ask its enclosing ac2vity for the informa2on Fragment ini2aliza2on code must be mindful of order of execu2on Does it depend on the surrounding ac2vity being loaded? Etc. Typically move oncreate code to onac2vitycreated

15 Fragment onclick listener Ac2vity <Bu[on android:onclick= onclickb1" /> Fragment <Bu[on /> // in fragment s java file Bu[on b = (Bu[on) getac2vity().findviewbyid(r.id.bu#on1); b.setonclicklistener(new public void onclick(view view) { );

16 Ac2vity that accepts parameters

17 Fragment that accepts parameters

18 Communica2on between fragments One ac2vity might contain mul2ple fragments The fragments may want to talk to each other Use ac2vity s getfragmentmanager method Its findfragmentbyid method can access any fragment that has an id Ac2vity act = getac2vity(); if(act.getresources().getconfigura2on().orienta2on == Configura2on.ORIENTATION_LANDSCAPE) { //update other fragment within this same ac2vity FragmentClass fragment = (FragmentClass) act.getfragmentmanager().findfragmentbyid(r.id.fid); fragment.methodname(parameters);

19 Fragment subclasses DialogFragment a fragment meant to be shown as a dialog box that pops up on the top of the current ac2vity ListFragment a fragment that shows a list of items as its main content PreferenceFragment a fragment whose main content is meant to allow the user to change sevngs for the app

20 Fragment Example 1 public class FragmentPortrait extends Fragment{ public View oncreateview(layoutinflater inflater, ViewGroup container, Bundle savedinstancestate) { // return super.oncreateview(inflater, container, savedinstancestate); return inflater.inflate(r.layout.portrait_fragment, container, false);

21 Fragment Example 1 ac2vity_main.xml file contains two fragments <Rela2veLayout xmlns:android="h<p://schemas.android.com/apk/res/android" xmlns:tools="h<p://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddinglec="@dimen/ ac2vity_horizontal_margin" android:paddingright="@dimen/ac2vity_horizontal_margin" android:paddingtop="@dimen/ac2vity_ver2cal_margin" android:paddingbo<om="@dimen/ac2vity_ver2cal_margin" tools:context=".mainac2vity"> <fragment android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/landscape_fragment" /> <fragment android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/portrait_fragment" /> </Rela2veLayout>

22 public class MainAc2vity extends AppCompatAc2vity protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); FragmentManager fragmentmanager = getfragmentmanager(); FragmentTransac2on fragmenttransac2on = fragmentmanager.begintransac2on(); Configura2on configinfo = getresources().getconfigura2on(); // Depending on the screen orientaaon replace with the correct fragment if(configinfo.orienta2on == Configura2on.ORIENTATION_LANDSCAPE){ FragmentLandscape fragmentlandscape = new FragmentLandscape(); fragmenttransac2on.replace(android.r.id.content, fragmentlandscape); else { FragmentPortrait fragmentportrait = new FragmentPortrait(); fragmenttransac2on.replace(android.r.id.content, fragmentportrait); // Schedule for the replacement of the Fragment as soon as possible fragmenttransac2on.commit();

23 Fragment Example 2 MainAc2vity.java ac2vity_main.xml ac2vity_main.xml - > contains one fragment fragment_main.xml MainFragment.java ac2vity_main.xml(land)- > contains two fragments fragment_main.xml fragment_details.xml DetailsFragment.java DetailsAc2vity.java ac2vity_details.xml

24 MainAc2vity.java public class MainAc2vity extends Ac2vity protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.ac<vity_main);

25 ac2vity_main.xml <LinearLayout xmlns:android="h<p://schemas.android.com/apk/res/android" xmlns:tools="h<p://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="top center" android:orienta2on="ver2cal" tools:context=".mainac2vity"> <fragment android:layout_width="match_parent" android:layout_height="match_parent" android:name="com.example.maozheng.fragmenmun.mainfragment" /> </LinearLayout>

26 ac2vity_main.xml(land) </LinearLayout > <fragment android:layout_width="wrap_content" android:layout_height="wrap_content" android:name="com.example.maozheng.fragmenmun.mainfragment" <fragment android:layout_width="wrap_content" android:layout_height="wrap_content" android:name="com.example.maozheng.fragmenmun.detailsfragment" </LinearLayout>

27 DetailsAc2vity.java public class DetailsAc2vity extends Ac2vity protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.ac<vity_details);

28 ac2vity_details.xml <LinearLayout xmlns:android="h<p://schemas.android.com/apk/res/android" xmlns:tools="h<p://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" ac2vity_horizontal_margin" android:gravity="top center" android:orienta2on="ver2cal" tools:context="com.example.maozheng.layoumun.detailsac2vity"> <fragment android:layout_width="match_parent" android:layout_height="match_parent" android:name="com.example.maozheng.fragmenmun.detailsfragment" </LinearLayout>

29 <LinearLayout > <RadioGroup android:orienta2on="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content"> <RadioBu<on android:text="leo" android:checked="true" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <RadioBu<on android:text="mike" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </RadioGroup> <ImageBu<on android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> fragment_main.xml

30 fragment_details.xml <LinearLayout xmlns:android="h<p://schemas.android.com/apk/res/android" xmlns:tools="h<p://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" ac2vity_horizontal_margin" android:gravity="top center" android:orienta2on="ver2cal" tools:context="com.example.maozheng.layoumun.detailsac2vity"> <TextView android:text="" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout>

31 Fragment Example 2 MainFragment.java /* * Shows more detailed informaaon about the currently selected ninja turtle. * In portrait mode, this pops up a second acavity. * In landscape mode, this updates the DetailsFragment within the same acavity. */ public void showdetailsaboutturtle() { RadioGroup group = (RadioGroup) getac2vity().findviewbyid(r.id.turtle_group); int id = group.getcheckedradiobu[onid(); if (getresources().getconfigura2on().orienta2on == Configura2on.ORIENTATION_LANDSCAPE) { // show in same acavity DetailsFragment frag = (DetailsFragment) getfragmentmanager().findfragmentbyid(r.id.fragment2); frag.setturtleid(id); else { // launch details as its own acavity Intent intent = new Intent(getAc2vity(), DetailsAc2vity.class); intent.putextra("turtle_id", id); startac2vity(intent);

32 Fragment Example 2 MainFragment.java /* * This method is called ajer the containing acavity is done being created. * This is a good place to a#ach event listeners and do other iniaalizaaon. public void onac2vitycreated(bundle savedinstancestate) { super.onac2vitycreated(savedinstancestate); // a#ach event listener to radio bu#on group RadioGroup group = (RadioGroup) getac2vity().findviewbyid(r.id.turtle_group); group.setoncheckedchangelistener(new RadioGroup.OnCheckedChangeListener() public void oncheckedchanged(radiogroup group, int checkedid) { updateturtleimage(); ); // a#ach click event listener to turtle image bu#on ImageBu[on img = (ImageBu[on) getac2vity().findviewbyid(r.id.turtle); img.setonclicklistener(new View.OnClickListener() public void onclick(view v) { showdetailsaboutturtle(); );

33 Fragment Example 2 MainFragment.java /* * Updates which turtle image is showing * based on which radio bu#on is currently checked. */ private void updateturtleimage() { ImageBu[on img = (ImageBu[on) getac2vity().findviewbyid(r.id.turtle); RadioGroup group = (RadioGroup) getac2vity().findviewbyid(r.id.turtle_group); int checkedid = group.getcheckedradiobu[onid(); if (checkedid == R.id.leo) { img.setimageresource(r.drawable.tmntleo); else if (checkedid == R.id.mike) { img.setimageresource(r.drawable.tmntmike); else if (checkedid == R.id.don) { img.setimageresource(r.drawable.tmntdon); else if (checkedid == R.id.raph) { img.setimageresource(r.drawable.tmntraph); if (getresources().getconfigura2on().orienta2on == Configura2on.ORIENTATION_LANDSCAPE) { showdetailsaboutturtle();

34 DetailsFragment.java /* * Sets the acavely selected ninja turtle text based on the given resource ID. */ public void setturtleid(int id) { int index; if (id == R.id.leo) { index = 0; else if (id == R.id.mike) { index = 1; else if (id == R.id.don) { index = 2; else { // if (id == R.id.raph) index = 3; String text = TURTLE_DETAILS[index]; TextView tv = (TextView) getac2vity().findviewbyid(r.id.turtle_info); tv.settext(text);

Fragments. Lecture 11

Fragments. Lecture 11 Fragments Lecture 11 Situational layouts Your app can use different layouts in different situations Different device type (tablet vs. phone vs. watch) Different screen size Different orientation (portrait

More information

Mobile Development Lecture 10: Fragments

Mobile Development Lecture 10: Fragments Mobile Development Lecture 10: Fragments Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Elgayyar.weebly.com Situational Layouts Your app can use different layout in different situations: different device type

More information

Fragments were added to the Android API in Honeycomb, API 11. The primary classes related to fragments are: android.app.fragment

Fragments were added to the Android API in Honeycomb, API 11. The primary classes related to fragments are: android.app.fragment FRAGMENTS Fragments An activity is a container for views When you have a larger screen device than a phone like a tablet it can look too simple to use phone interface here. Fragments Mini-activities, each

More information

Fragments. Fragments may only be used as part of an ac5vity and cannot be instan5ated as standalone applica5on elements.

Fragments. Fragments may only be used as part of an ac5vity and cannot be instan5ated as standalone applica5on elements. Fragments Fragments A fragment is a self- contained, modular sec5on of an applica5on s user interface and corresponding behavior that can be embedded within an ac5vity. Fragments can be assembled to create

More information

UI Fragment.

UI Fragment. UI Fragment 1 Contents Fragments Overviews Lifecycle of Fragments Creating Fragments Fragment Manager and Transactions Adding Fragment to Activity Fragment-to-Fragment Communication Fragment SubClasses

More information

Multiple devices. Use wrap_content and match_parent Use RelativeLayout/ConstraintLayout Use configuration qualifiers

Multiple devices. Use wrap_content and match_parent Use RelativeLayout/ConstraintLayout Use configuration qualifiers Multiple devices Multiple devices Use wrap_content and match_parent Use RelativeLayout/ConstraintLayout Use configuration qualifiers Create a new directory in your project's res/ and name it using the

More information

Tablets have larger displays than phones do They can support multiple UI panes / user behaviors at the same time

Tablets have larger displays than phones do They can support multiple UI panes / user behaviors at the same time Tablets have larger displays than phones do They can support multiple UI panes / user behaviors at the same time The 1 activity 1 thing the user can do heuristic may not make sense for larger devices Application

More information

Mobile Computing Fragments

Mobile Computing Fragments Fragments APM@FEUP 1 Fragments (1) Activities are used to define a full screen interface and its functionality That s right for small screen devices (smartphones) In bigger devices we can have more interface

More information

Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology

Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology Android App Development Mr. Michaud ICE Programs Georgia Institute of Technology Android Operating System Created by Android, Inc. Bought by Google in 2005. First Android Device released in 2008 Based

More information

ListView Containers. Resources. Creating a ListView

ListView Containers. Resources. Creating a ListView ListView Containers Resources https://developer.android.com/guide/topics/ui/layout/listview.html https://developer.android.com/reference/android/widget/listview.html Creating a ListView A ListView is a

More information

EMBEDDED SYSTEMS PROGRAMMING UI and Android

EMBEDDED SYSTEMS PROGRAMMING UI and Android EMBEDDED SYSTEMS PROGRAMMING 2016-17 UI and Android STANDARD GESTURES (1/2) UI classes inheriting from View allow to set listeners that respond to basic gestures. Listeners are defined by suitable interfaces.

More information

Mobile Programming Lecture 2. Layouts, Widgets, Toasts, and Event Handling

Mobile Programming Lecture 2. Layouts, Widgets, Toasts, and Event Handling Mobile Programming Lecture 2 Layouts, Widgets, Toasts, and Event Handling Lecture 1 Review How to edit XML files in Android Studio? What holds all elements (Views) that appear to the user in an Activity?

More information

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 2

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 2 Workshop 1. Compare different layout by using Change Layout button (Page 1 5) Relative Layout Linear Layout (Horizontal) Linear Layout (Vertical) Frame Layout 2. Revision on basic programming skill - control

More information

Diving into Android. By Jeroen Tietema. Jeroen Tietema,

Diving into Android. By Jeroen Tietema. Jeroen Tietema, Diving into Android By Jeroen Tietema Jeroen Tietema, 2015 1 Requirements 4 Android SDK 1 4 Android Studio (or your IDE / editor of choice) 4 Emulator (Genymotion) or a real device. 1 See https://developer.android.com

More information

User Interface Development. CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr.

User Interface Development. CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr. User Interface Development CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr. Rajiv Ramnath 1 Outline UI Support in Android Fragments 2 UI Support in the Android

More information

Intents. Your first app assignment

Intents. Your first app assignment Intents Your first app assignment We will make this. Decidedly lackluster. Java Code Java Code XML XML Preview XML Java Code Java Code XML Buttons that work

More information

CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015

CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015 CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015 Comment and Evaluation: This lab introduces us about Android SDK and how to write a program for Android platform. The calculator is pretty easy, everything

More information

CS 528 Mobile and Ubiquitous Computing Lecture 3: Android UI, WebView, Android Activity Lifecycle Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 3: Android UI, WebView, Android Activity Lifecycle Emmanuel Agu CS 528 Mobile and Ubiquitous Computing Lecture 3: Android UI, WebView, Android Activity Lifecycle Emmanuel Agu Android UI Design Example GeoQuiz App Reference: Android Nerd Ranch, pgs 1 30 App presents

More information

Getting Started. Dr. Miguel A. Labrador Department of Computer Science & Engineering

Getting Started. Dr. Miguel A. Labrador Department of Computer Science & Engineering Getting Started Dr. Miguel A. Labrador Department of Computer Science & Engineering labrador@csee.usf.edu http://www.csee.usf.edu/~labrador 1 Goals Setting up your development environment Android Framework

More information

ANDROID USER INTERFACE

ANDROID USER INTERFACE 1 ANDROID USER INTERFACE Views FUNDAMENTAL UI DESIGN Visual interface element (controls or widgets) ViewGroup Contains multiple widgets. Layouts inherit the ViewGroup class Activities Screen being displayed

More information

GUI Widget. Lecture6

GUI Widget. Lecture6 GUI Widget Lecture6 AnalogClock/Digital Clock Button CheckBox DatePicker EditText Gallery ImageView/Button MapView ProgressBar RadioButton Spinner TextView TimePicker WebView Android Widgets Designing

More information

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches EMBEDDED SYSTEMS PROGRAMMING 2016-17 UI Specification: Approaches UIS: APPROACHES Programmatic approach: UI elements are created inside the application code Declarative approach: UI elements are listed

More information

Mobile Computing Practice # 2c Android Applications - Interface

Mobile Computing Practice # 2c Android Applications - Interface Mobile Computing Practice # 2c Android Applications - Interface One more step in the restaurants application. 1. Design an alternative layout for showing up in landscape mode. Our current layout is not

More information

Android UI Development

Android UI Development Android UI Development Android UI Studio Widget Layout Android UI 1 Building Applications A typical application will include: Activities - MainActivity as your entry point - Possibly other activities (corresponding

More information

TextView. A label is called a TextView. TextViews are typically used to display a caption TextViews are not editable, therefore they take no input

TextView. A label is called a TextView. TextViews are typically used to display a caption TextViews are not editable, therefore they take no input 1 UI Components 2 UI Components 3 A label is called a TextView. TextView TextViews are typically used to display a caption TextViews are not editable, therefore they take no input - - - - - - -

More information

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) Application Components Hold the content of a message (E.g. convey a request for an activity to present an image) Lecture 2: Android Programming

More information

MVC Apps Basic Widget Lifecycle Logging Debugging Dialogs

MVC Apps Basic Widget Lifecycle Logging Debugging Dialogs Overview MVC Apps Basic Widget Lifecycle Logging Debugging Dialogs Lecture: MVC Model View Controller What is an App? Android Activity Lifecycle Android Debugging Fixing Rotations & Landscape Layouts Localization

More information

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State EMBEDDED SYSTEMS PROGRAMMING 2016-17 Application Tip: Saving State THE PROBLEM How to save the state (of a UI, for instance) so that it survives even when the application is closed/killed The state should

More information

Fragment Example Create the following files and test the application on emulator or device.

Fragment Example Create the following files and test the application on emulator or device. Fragment Example Create the following files and test the application on emulator or device. File: AndroidManifest.xml

More information

CS371m - Mobile Computing. More UI Action Bar, Navigation, and Fragments

CS371m - Mobile Computing. More UI Action Bar, Navigation, and Fragments CS371m - Mobile Computing More UI Action Bar, Navigation, and Fragments ACTION BAR 2 Options Menu and Action Bar prior to Android 3.0 / API level 11 Android devices required a dedicated menu button Pressing

More information

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation EMBEDDED SYSTEMS PROGRAMMING 2016-17 Application Tip: Managing Screen Orientation ORIENTATIONS Portrait Landscape Reverse portrait Reverse landscape ON REVERSE PORTRAIT Android: all four orientations are

More information

Android CardView Tutorial

Android CardView Tutorial Android CardView Tutorial by Kapil - Wednesday, April 13, 2016 http://www.androidtutorialpoint.com/material-design/android-cardview-tutorial/ YouTube Video We have already discussed about RecyclerView

More information

Initialising the Views (GameFragment) 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 5: Ultimate Tic-Tac-Toe Game: The Interface (Part III)

Initialising the Views (GameFragment) 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 5: Ultimate Tic-Tac-Toe Game: The Interface (Part III) 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 5: Ultimate Tic-Tac-Toe Game: The Interface (Part III) Dr Dimitris C. Dracopoulos Making a Move (GameFragment) Dimitris C. Dracopoulos 1/22 Initialising

More information

CS371m - Mobile Computing. More UI Navigation, Fragments, and App / Action Bars

CS371m - Mobile Computing. More UI Navigation, Fragments, and App / Action Bars CS371m - Mobile Computing More UI Navigation, Fragments, and App / Action Bars EFFECTIVE ANDROID NAVIGATION 2 Clicker Question Have you heard of the terms Back and Up in the context of Android Navigation?

More information

Android Overview. Most of the material in this sec5on comes from h6p://developer.android.com/guide/

Android Overview. Most of the material in this sec5on comes from h6p://developer.android.com/guide/ Android Overview Most of the material in this sec5on comes from h6p://developer.android.com/guide/ Android Overview A so=ware stack for mobile devices Developed and managed by Open Handset Alliance Open-

More information

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) Lecture 3: Android Life Cycle and Permission Android Lifecycle An activity begins its lifecycle when entering the oncreate() state If not

More information

The drawable/tile empty.xml file

The drawable/tile empty.xml file The X and O Symbols 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 3: Ultimate Tic-Tac-Toe Game: The Interface Dr Dimitris C. Dracopoulos Create them with the filenames x blue.png and o red.png in an

More information

FRAGMENTS.

FRAGMENTS. Fragments 69 FRAGMENTS In the previous section you learned what an activity is and how to use it. In a small-screen device (such as a smartphone), an activity typically fi lls the entire screen, displaying

More information

Create new Android project in Android Studio Add Button and TextView to layout Learn how to use buttons to call methods. Modify strings.

Create new Android project in Android Studio Add Button and TextView to layout Learn how to use buttons to call methods. Modify strings. Hello World Lab Objectives: Create new Android project in Android Studio Add Button and TextView to layout Learn how to use buttons to call methods. Modify strings.xml What to Turn in: The lab evaluation

More information

Android Application Model I

Android Application Model I Android Application Model I CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Rajiv Ramnath Reading: Big Nerd Ranch Guide, Chapters 3, 5 (Activities);

More information

Adaptation of materials: dr Tomasz Xięski. Based on presentations made available by Victor Matos, Cleveland State University.

Adaptation of materials: dr Tomasz Xięski. Based on presentations made available by Victor Matos, Cleveland State University. Creating dialogs Adaptation of materials: dr Tomasz Xięski. Based on presentations made available by Victor Matos, Cleveland State University. Portions of this page are reproduced from work created and

More information

Android Basics. Android UI Architecture. Android UI 1

Android Basics. Android UI Architecture. Android UI 1 Android Basics Android UI Architecture Android UI 1 Android Design Constraints Limited resources like memory, processing, battery à Android stops your app when not in use Primarily touch interaction à

More information

Embedded Systems Programming - PA8001

Embedded Systems Programming - PA8001 Embedded Systems Programming - PA8001 http://goo.gl/ydeczu Lecture 9 Mohammad Mousavi m.r.mousavi@hh.se Center for Research on Embedded Systems School of Information Science, Computer and Electrical Engineering

More information

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology Mobile Application Development Produced by David Drohan (ddrohan@wit.ie) Department of Computing & Mathematics Waterford Institute of Technology http://www.wit.ie User Interface Design" & Development -

More information

Agenda. Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen

Agenda. Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen Gill Cleeren Agenda Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen Lists and navigation Navigating from master to detail Optimizing the application Preparing

More information

Creating a Custom ListView

Creating a Custom ListView Creating a Custom ListView References https://developer.android.com/guide/topics/ui/declaring-layout.html#adapterviews Overview The ListView in the previous tutorial creates a TextView object for each

More information

Programming with Android: Android for Tablets. Dipartimento di Scienze dell Informazione Università di Bologna

Programming with Android: Android for Tablets. Dipartimento di Scienze dell Informazione Università di Bologna Programming with Android: Android for Tablets Luca Bedogni Marco Di Felice Dipartimento di Scienze dell Informazione Università di Bologna Outline Android for Tablets: A Case Study Android for Tablets:

More information

Arrays of Buttons. Inside Android

Arrays of Buttons. Inside Android Arrays of Buttons Inside Android The Complete Code Listing. Be careful about cutting and pasting.

More information

Hello World. Lesson 1. Android Developer Fundamentals. Android Developer Fundamentals. Layouts, and. NonCommercial

Hello World. Lesson 1. Android Developer Fundamentals. Android Developer Fundamentals. Layouts, and. NonCommercial Hello World Lesson 1 This work is licensed This under work a Creative is is licensed Commons under a a Attribution-NonCommercial Creative 4.0 Commons International Attribution- License 1 NonCommercial

More information

Android User Interface

Android User Interface Android Smartphone Programming Matthias Keil Institute for Computer Science Faculty of Engineering 20. Oktober 2014 Outline 1 Android User Interface 2 Multi-Language Support 3 Summary Matthias Keil Android

More information

Android User Interface Android Smartphone Programming. Outline University of Freiburg

Android User Interface Android Smartphone Programming. Outline University of Freiburg Android Smartphone Programming Matthias Keil Institute for Computer Science Faculty of Engineering 20. Oktober 2014 Outline 1 2 Multi-Language Support 3 Summary Matthias Keil 20. Oktober 2014 2 / 19 From

More information

Android Application Model I. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr.

Android Application Model I. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Android Application Model I CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Rajiv Ramnath 1 Framework Support (e.g. Android) 2 Framework Capabilities

More information

Android User Interface Overview. Most of the material in this sec7on comes from h8p://developer.android.com/guide/topics/ui/index.

Android User Interface Overview. Most of the material in this sec7on comes from h8p://developer.android.com/guide/topics/ui/index. Android User Interface Overview Most of the material in this sec7on comes from h8p://developer.android.com/guide/topics/ui/index.html Android User Interface User interface built using views and viewgroup

More information

More Effective Layouts

More Effective Layouts More Effective Layouts In past weeks, we've looked at ways to make more effective use of the presented display (e.g. elastic layouts, and separate layouts for portrait and landscape), as well as autogenerating

More information

Android HelloWorld - Example. Tushar B. Kute,

Android HelloWorld - Example. Tushar B. Kute, Android HelloWorld - Example Tushar B. Kute, http://tusharkute.com Anatomy of Android Application Anatomy of Android Application Java This contains the.java source files for your project. By default, it

More information

Building User Interface for Android Mobile Applications II

Building User Interface for Android Mobile Applications II Building User Interface for Android Mobile Applications II Mobile App Development 1 MVC 2 MVC 1 MVC 2 MVC Android redraw View invalidate Controller tap, key pressed update Model MVC MVC in Android View

More information

Android Application Development. By : Shibaji Debnath

Android Application Development. By : Shibaji Debnath Android Application Development By : Shibaji Debnath About Me I have over 10 years experience in IT Industry. I have started my career as Java Software Developer. I worked in various multinational company.

More information

Activities and Fragments

Activities and Fragments Activities and Fragments 21 November 2017 Lecture 5 21 Nov 2017 SE 435: Development in the Android Environment 1 Topics for Today Activities UI Design and handlers Fragments Source: developer.android.com

More information

Software Practice 3 Before we start Today s lecture Today s Task Team organization

Software Practice 3 Before we start Today s lecture Today s Task Team organization 1 Software Practice 3 Before we start Today s lecture Today s Task Team organization Prof. Hwansoo Han T.A. Jeonghwan Park 43 2 Lecture Schedule Spring 2017 (Monday) This schedule can be changed M A R

More information

Screen Slides. The Android Studio wizard adds a TextView to the fragment1.xml layout file and the necessary code to Fragment1.java.

Screen Slides. The Android Studio wizard adds a TextView to the fragment1.xml layout file and the necessary code to Fragment1.java. Screen Slides References https://developer.android.com/training/animation/screen-slide.html https://developer.android.com/guide/components/fragments.html Overview A fragment can be defined by a class and

More information

ANDROID APPS DEVELOPMENT FOR MOBILE GAME

ANDROID APPS DEVELOPMENT FOR MOBILE GAME ANDROID APPS DEVELOPMENT FOR MOBILE GAME Application Components Hold the content of a message (E.g. convey a request for an activity to present an image) Lecture 2: Android Layout and Permission Present

More information

Overview. What are layouts Creating and using layouts Common layouts and examples Layout parameters Types of views Event listeners

Overview. What are layouts Creating and using layouts Common layouts and examples Layout parameters Types of views Event listeners Layouts and Views http://developer.android.com/guide/topics/ui/declaring-layout.html http://developer.android.com/reference/android/view/view.html Repo: https://github.com/karlmorris/viewsandlayouts Overview

More information

Our First Android Application

Our First Android Application Mobile Application Development Lecture 04 Imran Ihsan Our First Android Application Even though the HelloWorld program is trivial in introduces a wealth of new ideas the framework, activities, manifest,

More information

Orientation & Localization

Orientation & Localization Orientation & Localization Overview Lecture: Open Up Your My Pet App Handling Rotations Serializable Landscape Layouts Localization Alert Dialogs 1 Handling Rotations When the device is rotated, the device

More information

Lab 1 - Setting up the User s Profile UI

Lab 1 - Setting up the User s Profile UI Lab 1 - Setting up the User s Profile UI Getting started This is the first in a series of labs that allow you to develop the MyRuns App. The goal of the app is to capture and display (using maps) walks

More information

CS 4518 Mobile and Ubiquitous Computing Lecture 5: Rotating Device, Saving Data, Intents and Fragments Emmanuel Agu

CS 4518 Mobile and Ubiquitous Computing Lecture 5: Rotating Device, Saving Data, Intents and Fragments Emmanuel Agu CS 4518 Mobile and Ubiquitous Computing Lecture 5: Rotating Device, Saving Data, Intents and Fragments Emmanuel Agu Administrivia Moved back deadlines for projects 2, 3 and final project See updated schedule

More information

EMBEDDED SYSTEMS PROGRAMMING Application Basics

EMBEDDED SYSTEMS PROGRAMMING Application Basics EMBEDDED SYSTEMS PROGRAMMING 2015-16 Application Basics APPLICATIONS Application components (e.g., UI elements) are objects instantiated from the platform s frameworks Applications are event driven ( there

More information

CS 4518 Mobile and Ubiquitous Computing Lecture 3: Android UI Design in XML + Examples. Emmanuel Agu

CS 4518 Mobile and Ubiquitous Computing Lecture 3: Android UI Design in XML + Examples. Emmanuel Agu CS 4518 Mobile and Ubiquitous Computing Lecture 3: Android UI Design in XML + Examples Emmanuel Agu Resources Android Resources Resources? Images, strings, dimensions, layout files, menus, etc that your

More information

Android development. Outline. Android Studio. Setting up Android Studio. 1. Set up Android Studio. Tiberiu Vilcu. 2.

Android development. Outline. Android Studio. Setting up Android Studio. 1. Set up Android Studio. Tiberiu Vilcu. 2. Outline 1. Set up Android Studio Android development Tiberiu Vilcu Prepared for EECS 411 Sugih Jamin 15 September 2017 2. Create sample app 3. Add UI to see how the design interface works 4. Add some code

More information

Vienos veiklos būsena. Theory

Vienos veiklos būsena. Theory Vienos veiklos būsena Theory While application is running, we create new Activities and close old ones, hide the application and open it again and so on, and Activity can process all these events. It is

More information

Embedded Systems Programming - PA8001

Embedded Systems Programming - PA8001 Embedded Systems Programming - PA8001 http://goo.gl/ydeczu Lecture 8 Mohammad Mousavi m.r.mousavi@hh.se Center for Research on Embedded Systems School of Information Science, Computer and Electrical Engineering

More information

Programmatically Working with Android Fragments

Programmatically Working with Android Fragments Visit: www.intertech.com/blog Programmatically Working with Android Fragments Fragments (since Android ) can be used to organize the display of information in Activities, especially those that have to

More information

CS 4518 Mobile and Ubiquitous Computing Lecture 4: WebView (Part 2) Emmanuel Agu

CS 4518 Mobile and Ubiquitous Computing Lecture 4: WebView (Part 2) Emmanuel Agu CS 4518 Mobile and Ubiquitous Computing Lecture 4: WebView (Part 2) Emmanuel Agu WebView Widget WebView Widget A View that displays web pages Can be used for creating your own web browser OR just display

More information

Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB)

Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB) Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB) In this exercise, we will create a simple Android application that uses IBM Bluemix Cloudant NoSQL DB. The application

More information

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi ACTIVITY, FRAGMENT, NAVIGATION Roberto Beraldi Introduction An application is composed of at least one Activity GUI It is a software component that stays behind a GUI (screen) Activity It runs inside the

More information

Java & Android. Java Fundamentals. Madis Pink 2016 Tartu

Java & Android. Java Fundamentals. Madis Pink 2016 Tartu Java & Android Java Fundamentals Madis Pink 2016 Tartu 1 Agenda» Brief background intro to Android» Android app basics:» Activities & Intents» Resources» GUI» Tools 2 Android» A Linux-based Operating System»

More information

CS 4330/5390: Mobile Application Development Exam 1

CS 4330/5390: Mobile Application Development Exam 1 1 Spring 2017 (Thursday, March 9) Name: CS 4330/5390: Mobile Application Development Exam 1 This test has 8 questions and pages numbered 1 through 7. Reminders This test is closed-notes and closed-book.

More information

Fragments and the Maps API

Fragments and the Maps API Fragments and the Maps API Alexander Nelson October 6, 2017 University of Arkansas - Department of Computer Science and Computer Engineering Fragments Fragments Fragment A behavior or a portion of a user

More information

When programming in groups of people, it s essential to version the code. One of the most popular versioning tools is git. Some benefits of git are:

When programming in groups of people, it s essential to version the code. One of the most popular versioning tools is git. Some benefits of git are: ETSN05, Fall 2017, Version 1.0 Software Development of Large Systems Lab 2 preparations Read through this document carefully. In order to pass lab 2, you will need to understand the topics presented in

More information

Real-Time Embedded Systems

Real-Time Embedded Systems Real-Time Embedded Systems DT8025, Fall 2016 http://goo.gl/azfc9l Lecture 8 Masoumeh Taromirad m.taromirad@hh.se Center for Research on Embedded Systems School of Information Technology 1 / 51 Smart phones

More information

Android & iphone. Amir Eibagi. Localization

Android & iphone. Amir Eibagi. Localization Android & iphone Amir Eibagi Localization Topics Android Localization: Overview Language & Strings Country/region language variations Images & Media Currency, date & Time iphone Localization Language &

More information

LECTURE NOTES OF APPLICATION ACTIVITIES

LECTURE NOTES OF APPLICATION ACTIVITIES Department of Information Networks The University of Babylon LECTURE NOTES OF APPLICATION ACTIVITIES By College of Information Technology, University of Babylon, Iraq Samaher@inet.uobabylon.edu.iq The

More information

UI (User Interface) overview Supporting Multiple Screens Touch events and listeners

UI (User Interface) overview Supporting Multiple Screens Touch events and listeners http://www.android.com/ UI (User Interface) overview Supporting Multiple Screens Touch events and listeners User Interface Layout The Android user interface (UI) consists of screen views (one or more viewgroups

More information

Upon completion of the second part of the lab the students will have:

Upon completion of the second part of the lab the students will have: ETSN05, Fall 2017, Version 2.0 Software Development of Large Systems Lab 2 1. INTRODUCTION The goal of lab 2 is to introduce students to the basics of Android development and help them to create a starting

More information

Programming with Android: Introduction. Layouts. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna

Programming with Android: Introduction. Layouts. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna Programming with Android: Introduction Layouts Luca Bedogni Marco Di Felice Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna Views: outline Main difference between a Drawable and

More information

O X X X O O X O X. Tic-Tac-Toe. 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 2: The Ultimate Tic-Tac-Toe Game

O X X X O O X O X. Tic-Tac-Toe. 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 2: The Ultimate Tic-Tac-Toe Game Tic-Tac-Toe 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 2: The Ultimate Tic-Tac-Toe Game Dr Dimitris C. Dracopoulos O X X X O O X O X The Ultimate Tic-Tac-Toe: Rules of the Game Dimitris C. Dracopoulos

More information

Topics of Discussion

Topics of Discussion Reference CPET 565 Mobile Computing Systems CPET/ITC 499 Mobile Computing Fragments, ActionBar and Menus Part 3 of 5 Android Programming Concepts, by Trish Cornez and Richard Cornez, pubslihed by Jones

More information

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar Mobile Application Development Higher Diploma in Science in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology

More information

CE881: Mobile & Social Application Programming

CE881: Mobile & Social Application Programming CE881: Mobile & Social Application Programming, s, s and s Jialin Liu Senior Research Officer Univerisity of Essex 6 Feb 2017 Recall of lecture 3 and lab 3 :) Please download Kahoot or open a bowser and

More information

Developed and taught by well-known Contact author and developer. At public for details venues or onsite at your location.

Developed and taught by well-known Contact author and developer. At public for details venues or onsite at your location. 2011 Marty Hall Android Programming Basics Originals of Slides and Source Code for Examples: http://www.coreservlets.com/android-tutorial/ Customized Java EE Training: http://courses.coreservlets.com/

More information

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE)

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE) PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE) Network Connection Web Service K Candra Brata andra.course@gmail.com Mobille App Lab 2015-2016 Network Connection http://developer.android.com/training/basics/network-ops/connecting.html

More information

Mobile Programming Lecture 1. Getting Started

Mobile Programming Lecture 1. Getting Started Mobile Programming Lecture 1 Getting Started Today's Agenda About the Android Studio IDE Hello, World! Project Android Project Structure Introduction to Activities, Layouts, and Widgets Editing Files in

More information

ELET4133: Embedded Systems. Topic 15 Sensors

ELET4133: Embedded Systems. Topic 15 Sensors ELET4133: Embedded Systems Topic 15 Sensors Agenda What is a sensor? Different types of sensors Detecting sensors Example application of the accelerometer 2 What is a sensor? Piece of hardware that collects

More information

Produced by. Mobile Application Development. Eamonn de Leastar

Produced by. Mobile Application Development. Eamonn de Leastar Mobile Application Development Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie A First

More information

INTRODUCTION TO ANDROID

INTRODUCTION TO ANDROID INTRODUCTION TO ANDROID 1 Niv Voskoboynik Ben-Gurion University Electrical and Computer Engineering Advanced computer lab 2015 2 Contents Introduction Prior learning Download and install Thread Android

More information

Mobile Application Development - Android

Mobile Application Development - Android Mobile Application Development - Android MTAT.03.262 Satish Srirama satish.srirama@ut.ee Goal Give you an idea of how to start developing Android applications Introduce major Android application concepts

More information

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar Mobile Application Development Higher Diploma in Science in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology

More information

Login with Amazon. Getting Started Guide for Android apps

Login with Amazon. Getting Started Guide for Android apps Login with Amazon Getting Started Guide for Android apps Login with Amazon: Getting Started Guide for Android Copyright 2017 Amazon.com, Inc., or its affiliates. All rights reserved. Amazon and the Amazon

More information

Developing Android Applications Introduction to Software Engineering Fall Updated 1st November 2015

Developing Android Applications Introduction to Software Engineering Fall Updated 1st November 2015 Developing Android Applications Introduction to Software Engineering Fall 2015 Updated 1st November 2015 Android Lab 3 & Midterm Additional Concepts No Class Assignment 2 Class Plan Android : Additional

More information

CS 528 Mobile and Ubiquitous Computing Lecture 4a: Fragments, Camera Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 4a: Fragments, Camera Emmanuel Agu CS 528 Mobile and Ubiquitous Computing Lecture 4a: Fragments, Camera Emmanuel Agu Fragments Recall: Fragments Sub-components of an Activity (screen) An activity can contain multiple fragments, organized

More information