Programming with Android: Layouts, Widgets and Events. Dipartimento di Scienze dell Informazione Università di Bologna

Size: px
Start display at page:

Download "Programming with Android: Layouts, Widgets and Events. Dipartimento di Scienze dell Informazione Università di Bologna"

Transcription

1 Programming with Android: Layouts, Widgets and Events Luca Bedogni Marco Di Felice Dipartimento di Scienze dell Informazione Università di Bologna

2 Outline Components of an Activity ViewGroup: definition ViewGroup: examples Widget: definition Widget: examples Event Management: Event Listeners Event Management: Event Handlers Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 2

3 Android Applications Design Ø Developing an Android Application means using in a proper way the Android basic components Activity Fragment Intent Service Layout Views Content Providers Broadcast Receiver Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 3

4 Android: Views and Layouts Components of the User Interface (UI) of an Activity ViewGroup View ² View container ² Responsible for placing other Views on the display ² Every layout must extend a ViewGroup ² Basic component of the UI ² Can handle/produce events ² Every new UI component must extend a View Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 4

5 Android: ViewGroups ViewGroup à define the placement of the Views. Ø Defined in Java code (within the Activity file) Ø Defined in XML (layout file) ² Use XML tags to place a ViewGroup ² Place a View within a ViewGroup using these XML attributes android:layout_width android:layout_height } match_parent wrap_content Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 5

6 Android: ViewGroups <?xml version="1.0" encoding="utf- 8"?> ACTIVITY_MAIN.XML <LinearLayout xmlns:android=" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation= vertical" > <Button android:layout_width= match_parent" android:layout_height="wrap_content" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 6

7 Android: ViewGroups <?xml version="1.0" encoding="utf- 8"?> <LinearLayout xmlns:android=" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation= vertical" > <Button android:layout_width= match_parent" android:layout_height="wrap_content" /> <Button android:layout_width="wrap_content" android:layout_height= match_parent" /> </LinearLayout> Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 7 ACTIVITY_MAIN.XML

8 Android: ViewGroups List of most common Layouts provided by Android Name XML Tag Description LinearLayout RelativeLayout TableLayout FrameLayout AbsoluteLayout <LinearLayout> </LinearLayout> <RelativeLayout> </RelativeLayout> <TableLayout> </TableLayout> <FrameLayout> </FrameLayout> <AbsoluteLayout> </AbsoluteLayout> arrange Views by aligning them on a single row or column arrange Views through relative positions arrange Views into rows and columns arrange a single View within a Layout arrange Views through absolute positions ² A Layout can be declared within another Layout Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 8

9 Android: ViewGroups List of most common Layouts provided by Android Name XML Tag Description LinearLayout RelativeLayout TableLayout FrameLayout AbsoluteLayout <LinearLayout> </LinearLayout> <RelativeLayout> </RelativeLayout> <TableLayout> </TableLayout> <FrameLayout> </FrameLayout> <AbsoluteLayout> </AbsoluteLayout> arrange Views by aligning them on a single row or column arrange Views through relative positions arrange Views into rows and columns arrange a single View within a Layout arrange Views through absolute positions ² A Layout can be declared within another Layout Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 9

10 Android: ViewGroups LinearLayout à view group that aligns all children in a single direction, vertically or horizontally. ² Orientation can be declared through XML tag android:orientation= HORIZONTAL VERTICAL ² Orientation can also be declared in Java through setorientation(int orientation) ² Views has also other two attributes: gravity weigth Align the View with its parent How much space is assigned to the View Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 10

11 Android: ViewGroups ORIENTATION VERTICAL ORIENTATION HORIZONTAL Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 11

12 Android: ViewGroups <?xml version="1.0" encoding="utf- 8"?> <LinearLayout xmlns:android=" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <!- - Also horizontal à <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/buttonstring1" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/buttonstring2" /> </LinearLayout> Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 12

13 Android: ViewGroups ² For each View in a LinearLayout, we can set the android:weight XML property (integer value) Importance of a View, how much it can expand <LinearLayout> <Button android:layout_width=match_parent android:weight=1/> <Button android:layout_width=match_parent android:weight=1/> </LinearLayout> Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 13

14 Android: ViewGroups ² For each View in a LinearLayout, we can set the android:weight XML property (integer value) Importance of a View, how much it can expand <LinearLayout> <Button android:layout_width=match_parent android:weight=1/> <Button android:layout_width=match_parent android:weight=2/> </LinearLayout> Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 14

15 Android: ViewGroups ² For each View in a LinearLayout, we can set the layout_gravity XML property Align a View with its parent (LinearLayout) <LinearLayout> <Button android:layout_width=match_parent android:weigth=1/> <Button android:layout_width=match_parent android:layout_gravity= center_vertical android:weight=2/> </LinearLayout> Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 15

16 Android: ViewGroups List of most common Layouts provided by Android Name XML Tag Description LinearLayout RelativeLayout TableLayout FrameLayout AbsoluteLayout <LinearLayout> </LinearLayout> <RelativeLayout> </RelativeLayout> <TableLayout> </TableLayout> <FrameLayout> </FrameLayout> <AbsoluteLayout> </AbsoluteLayout> arrange Views by aligning them on a single row or column arrange Views through relative positions arrange Views into rows and columns arrange a single View within a Layout arrange Views through absolute positions ² A Layout can be declared within another Layout Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 16

17 Android: ViewGroups RelativeLayout à View group that displays all Views based on relative positions. RELATIVE= COMPARED to the PARENT LAYOUT android:alignparentbottom= true false android:alignparenttop= true false android:alignparentleft= true false android:alignparentright= true false android:alignparentstart= true false android:alignparentend= true false Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 17

18 Android: ViewGroups RelativeLayout à View group that displays all Views based on relative positions. RELATIVE= COMPARED to SIBLING VIEWs android:toleftof= ID android:torightof= ID android:tostartof= ID android:toendof= ID XML Identifier of the View used as reference point Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 18

19 Android: ViewGroups <?xml version="1.0" encoding="utf- 8"?> <RelativeLayout xmlns:android=" android:layout_width="match_parent" android:layout_height="match_parent" > ACTIVITY_MAIN.XML <EditText android:text="username" android:inputtype="text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentright="true" > </EditText> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="username" /> CONTINUE Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 19

20 Android: ViewGroups <EditText android:text="password" android:inputtype="textpassword" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentright="true" > </EditText> ACTIVITY_MAIN.XML <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="password" /> </RelativeLayout> Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 20

21 Android: ViewGroups List of most common Layouts provided by Android Name XML Tag Description LinearLayout RelativeLayout TableLayout FrameLayout AbsoluteLayout <LinearLayout> </LinearLayout> <RelativeLayout> </RelativeLayout> <TableLayout> </TableLayout> <FrameLayout> </FrameLayout> <AbsoluteLayout> </AbsoluteLayout> arrange Views by aligning them on a single row or column arrange Views through relative positions arrange Views into rows and columns arrange a single View within a Layout arrange Views through absolute positions ² A Layout can be declared within another Layout Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 21

22 Android: ViewGroups TableLayout à View group that arranges all Views into rows and columns (as an HTML table). PROPERTIES 1. Consists of a list of TableRaw objects, each defyining a raw of the Table. 2. The width of a column is defined by the row with the widest cell in that column. 3. Cells can be empty, or can span multiple columns (like in HTML). 4. Border lines of the cells are not displayed. Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 22

23 Android: ViewGroups TableLayout à View group that arranges all Views into rows and columns (as an HTML table). ADDITIONAL XML attributes android:layout_column android:layout_span android:collapsecolumn android:shrinkcolumns android:stretchcolumns } Apply only to width layout_width is always WRAP_CONTENT layout_height is WRAP_CONTENT (default) Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 23

24 Android: ViewGroups <?xml version="1.0" encoding="utf- 8"?> <TableLayout android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android=schemas.android.com/apk/res/android > <TableRow android:layout_width="wrap_content" android:layout_height="wrap_content <Button android:layout_width="wrap_content android:layout_height="wrap_content android:text="button" /> <Button android:layout_width="match_parent" android:layout_height="match_parent" android:text="button" /> <Button android:layout_width="match_parent" android:layout_height="match_parent" android:text="button" /> </TableRow> Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 24 ACTIVITY_MAIN.XML CONTINUE

25 Android: ViewGroups <TableRow android:layout_width="wrap_content" android:layout_height="wrap_content" ACTIVITY_MAIN.XML <Button android:layout_column="1" android:layout_span="2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button"> </Button> </TableRow> </TableLayout> Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 25

26 Android: ViewGroups List of most common Layouts provided by Android Name XML Tag Description LinearLayout RelativeLayout TableLayout FrameLayout AbsoluteLayout <LinearLayout> </LinearLayout> <RelativeLayout> </RelativeLayout> <TableLayout> </TableLayout> <FrameLayout> </FrameLayout> <AbsoluteLayout> </AbsoluteLayout> arrange Views by aligning them on a single row or column arrange Views through relative positions arrange Views into rows and columns arrange a single View within a Layout arrange Views through absolute positions ² A Layout can be declared within another Layout Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 26

27 Android: ViewGroups FrameLayout à Block out an area on the screen to display a single item (i.e. a single View). ² It should be used to display a single View within the Layout ² Multiple views can be controlled through android:layout_gravity AbsoluteLayout à Arrange Views on the screen by specifying absolute x-y positions of each View. ² Deprecated, since it is dependant of the screen resolution Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 27

28 Android: Views and Layouts Components of the User Interface (UI) of an Activity ViewGroup View ² View container. ² Responsible for placing other Views on the display ² Every layout must extend a ViewGroup ² Basic component of the UI ² Can handle/produce events ² Every new UI component must extend a View Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 28

29 Android: Views objects Views à basic building blocks for user interface components ² Rectangular area of the screen ² Responsible for drawing ² Responsible for event handling EXAMPLEs of VIEWS objects: GoogleMap WebView Widgets à topic of the day User-defined Views Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 29

30 Android: Views objects Widgetà Pre-defined interactive UI components (android.view.widgets) TextView EditText Button ToggleButton Spinner DataPicker Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 30

31 Widgets: Java and XML code Widgets can be defined in the XML layout files < TextView android:layout_width="match_parent" android:layout_height="wrap_content android:visibility="visible android:enabled="true android:scrollbars="vertical android:text= Hello World /> PROPERTIES, defined through android: attributes Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 31

32 Widgets: Java and XML code Widgets can be defined in XML and accessed from Java < TextView /> XML public TextView text; text=(textview)findviewbyid(r.id.name1); JAVA CAST REQUIRED public TextView text; text=new TextView(); Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 32

33 Widgets: Java and XML code ² Each Widget can have a focus and a visibility, based on the user s interaction. Ø The user can force a focus to a specific component through the requestfocus() method. Ø The user can modify the visibility of a specific component through the setvisibility(int) method. public TextView text; text=(textview) findviewbyid(r.id.name1); text.setvisibility(true) text.requestfocus(); Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 33

34 Widgets: Hierarchy of the classes Ø Widgets are organized on a hierarchy of classes View TextView ImageView EditView Button CheckedTextView AutoCompleteTextView CompoundButton CheckBox RadioButton ToggleButton Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 34

35 Widgets: TextView ² XML tags: <TextView> </TextView> Ø Could be filled with strings or HTML markups Ø Not directly editable by users Ø Usually used to display static informations <TextView android:layout_width="wrap_content" android:layout_height="wrap_content /> Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 35

36 Widgets: TextView methods Ø Methods to place some texts inside a TextView ² public void settext(charsequence text) ² public CharSequence gettext() ² public void setsingleline(boolean singleline) ² public void sethorizontallyscrolling(boolean enable) ² public void setlines(int lines) ² public void setellipsize(textutils.truncateat where) ² public void sethints(charsequence hints) ² TextUtils.TruncateAt.END ² TextUtils.TruncateAt.MARQUEE ² TextUtils.TruncateAt.MIDDLE ² TextUtils.TruncateAt.START Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 36

37 Widgets: Linkify elements ² Simple strings could be linkified automatically. Ø How? Pick a normal string, and use Linkify.addLinks() to define the kind of links to be created. Ø Could manage: Web addresses, s, phone numbers, Maps TextView textview=(textview) findviewbyid(r.id.output); Linkify.addLinks(textView, Linkify.WEB_URLS Linkify.WEB_ADDRESSES Linkify.PHONE_NUMBERS ); Linkify.addLinks(textView, Linkify.ALL); ² It is possible to define custom Linkify objects... Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 37

38 Widgets: EditText ² XML tags: <EditText> </EditText> Ø Similar to a TextView, but editable by the users Ø An appropriate keyboard will be displayed <EditText android:id="@+id/edittext android:inputtype= textcapsentences textcapwords textautocorrect textpassword textmultilane /> Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 38

39 Widgets: Button ² XML tags: <Button> </Button> Ø Subclass of a TextView, but not directly editable by users Ø Can generate events related to click, long click, etc <Button android:text="@string/textbutton" android:id="@+id/idbutton" android:background="@color/blue /> <selector> <item android:color="#ff android:state_pressed="true > </item> </selector> ² CompoundButton: Button + state (checked/unchecked) Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 39 res/color/blue.xml

40 Widgets: Button and CompoundButton checkbox CompoundButton XML tags: <checkbox> <checkbox android:layout_width="wrap_content android:layout_height="wrap_content android:text="checkbox android:checked="true /> Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 40

41 Widgets: Button and CompoundButton checkbox CompoundButton ² public boolean ischecked(): Returns true if the button is checked, false otherwise. ² public boolean setchecked(bool) Listener: oncheckedchangelistener Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 41

42 Widgets: Button and CompoundButton radiobutton CompoundButton XML tags: <RadioButton> <RadioButton android:layout_width="wrap_content android:layout_height="wrap_content android:text="buttonradio android:checked="true /> Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 42

43 Widgets: Button and CompoundButton radiobutton CompoundButton ² Define multiple (mutualexclusive) options through a <RadioGroup> tag. ² Only one button can be checked within the same RadioGroup. Listener: OnCheckedChangeListener Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 43

44 Widgets: Button and CompoundButton <RadioGroup android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical > <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="option 1" android:checked="true /> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="option 2 /> </RadioGroup> Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 44

45 Widgets: Button and CompoundButton togglebutton CompoundButton ² It can assume only 2 states: checked/unchecked ² Different labels for the states with: android:texton and android:textoff XML attributes. Listener: OnCheckedChangeListener Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 45

46 Widgets: Button and CompoundButton togglebutton CompoundButton XML tags: <ToggleButton> <ToggleButton android:layout_width="wrap_content android:layout_height="wrap_content android:texton="button ON android:textoff="button OFF android:checked="false /> Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 46

47 Widgets: Spinners Spinner component XML tags: <Spinner> ² Provides a quick way to select values from a specific set. ² The spinner value-set can be defined in XML (through the entries tag) or through the SpinnerAdapter in Java Listener: OnItemSelectedListener Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 47

48 Widgets: Spinners Spinner component XML tags: <Spinner> <resources> <string-array name="stringoptions"> <item>option 1</item> <item>option 2</item> <item>option 3</item> <item>option 4</item> </string-array> </resources> res/values.xml <Spinner android:layout_width="wrap_content" android:layout_height="wrap_content" /> Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 48

49 Widgets: Button and CompoundButton DataPicker component XML tags: <DataPicker> <DatePicker android:layout_width="wrap_content android:layout_height="wrap_content android:endyear="1990 android:startyear="2014 android:maxdate="10/10/2014 /> Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 49

50 Widgets: ImageView ² ImageView: subclass of View object. ² Some methods to manipulate an image: void setscaletype(enum scaletype) void setalpha(double alpha) void setcolorfilter(colorfilter color) CENTER, CENTER_CROP, CENTER_INSIDE, FIT_CENTER, FIT_END, FIT_START, FIT_XY, MATRIX Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 50

51 Widgets: ImageView ImageView component XML tags: <ImageView> <ImageView android:layout_width="wrap_content android:layout_height="wrap_content /> Source: android.jpg in drawable/ Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 51

52 Views and Events Views/Widgets are interactive components à Upon certain action from the user, an appropriate event will be fired click, long click, focus, items selected, items checked,drag, How to handle the events generated by a View? 1. Directly from XML 2. Through Event Listeners (general, recommended) 3. Through Event Handlers (general) Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 52

53 Views and Events ² For a limited set of components, it is possible to manage the events through callbacks indicated in the XML layout. <Button android:text="@string/textbutton android:id="@+id/idbutton android:onclick= dosomething /> XML Layout File Java code public void dosomething(view w) { // Code to manage the click event } Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 53

54 Views and Events Views/Widgets are interactive components à Upon certain action from the user, an appropriate event will be fired click, long click, focus, items selected, items checked,drag, How to handle the events generated by a View? 1. Directly from XML 2. Through Event Listeners (general, recommended) 3. Through Event Handlers (general) Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 54

55 Views and Events Each View contains a collection of nested interfaces (listeners). Ø Each listener handles a single event Ø Each listener contains a single callback method Ø The callback is invoked at occurrence of the event. Button interface OnClickListener public abstract void onclick(view v) {} Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 55

56 Views and Events: ActionListener To handle events through the ActionListener mechanism: 1. Make the Activity implement the Listener Interface corrisponding to the Event generated by the View (Click Event in this example) public class ExampleActivity extends Activity implements OnClickListener { } Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 56

57 Views and Events: ActionListener To handle events through the ActionListener mechanism: 2. Implement the abstract method of the Listener à this will be the callback method when the Event is fired public void onclick(view w) { // Place here the code to manage the event } (Click Event in this example) Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 57

58 Views and Events: ActionListener To handle events through the ActionListener mechanism: 3. Associate the ActionListener to the View through the method seteventlistener(this) Button mybutton=(button) findviewbyid(r.id.button1); mybutton.setonclicklistener(this); (Click Event in this example) Luca Bedogni, Marco Di Felice - Programming with Android ViewGroups, Views and Events 58

59 Views and Events: ActionListener LIST OF ACTIONLISTENER INTERFACES Ø interface OnClickListener abstract method: onclick() Ø interface OnLongClickListener abstract method: onlongclick() Ø interface OnFocusChangeListener abstract method: onfocuschange() Ø interface OnKeyListener abstract method: onkey() Ø interface OnCheckedChangeListener abstract method: oncheckedchanged() Ø interface OnItemSelectedListener abstract method: onitemselected() Ø interface OnCheckedChangeListener abstract method: oncheckedchanged() Ø interface OnItemSelectedListener abstract method: onitemselected() Ø interface OnTouchListener abstract method: ontouch() Ø interface OnCreateContextMenuListener abstract method: oncreatecontextmenu() Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 59

60 Views and Events: ActionListener It is also possible to fire an event directly from the Java code (without user s interaction) useful for debugging! ² Can be done through performevent() events ² The corresponding listener (if set) will be invoked Button button=(button)findviewbyid(r.id.buttonnext); button.performclick(); (c) Luca Bedogni 2012 Luca Bedogni, Marco Di Felice Events and Widgets // Callback method public void onclick(view v) {. } 60

61 Views and Events Views/Widgets are interactive components à Upon certain action from the user, an appropriate event will be fired click, long click, focus, items selected, items checked,drag, How to handle the events generated by a View? 1. Directly from XML 2. Through Event Listeners (general, recommended) 3. Through Event Handlers (general) Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 61

62 Views and Events: Event Handlers Event Handlers à Some Views have callback methods to handle specific events (example: When a Button is touched à ontouchevent() called) PROBLEM: to intercept an event, you must extend the View class and override the callback method not very practical! IN PRACTICE: ² Events Handlers are used for custom (user-defined) components ² Events Listeners are used for common View/Widget components Luca Bedogni, Marco Di Felice - Programming with Android (c) ViewGroups, Luca Bedogni 2012 Views and Events 62

Programming with Android: Widgets and Events. Luca Bedogni. Dipartimento di Scienze dell Informazione Università di Bologna

Programming with Android: Widgets and Events. Luca Bedogni. Dipartimento di Scienze dell Informazione Università di Bologna Programming with Android: Widgets and Events Luca Bedogni Dipartimento di Scienze dell Informazione Università di Bologna Outline What is a Widget? Widget: TextView and EditText Widget: Button and CompoundButton

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

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

Programming with Android: Introduction. Layouts. Luca Bedogni. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna Programming with Android: Introduction Layouts Luca Bedogni Dipartimento di Informatica: Scienza e Ingegneria Uniersità di Bologna Views: outline Main difference between a Drawable and a View is reaction

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

Android UI: Overview

Android UI: Overview 1 Android UI: Overview An Activity is the front end component and it can contain screens. Android screens are composed of components or screen containers and components within the containers Screen containers

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

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

Graphical User Interfaces

Graphical User Interfaces Graphical User Interfaces Some suggestions Avoid displaying too many things Well-known anti-patterns Display useful content on your start screen Use action bars to provide consistent navigation Keep your

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

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

Mobile Software Development for Android - I397

Mobile Software Development for Android - I397 1 Mobile Software Development for Android - I397 IT COLLEGE, ANDRES KÄVER, 2015-2016 EMAIL: AKAVER@ITCOLLEGE.EE WEB: HTTP://ENOS.ITCOLLEGE.EE/~AKAVER/2015-2016/DISTANCE/ANDROID SKYPE: AKAVER Layout fundamentals

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

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

Creating a User Interface

Creating a User Interface Creating a User Interface Developing for Android devices is a complicated process that requires precision to work with. Android runs on numerous devices from smart-phones to tablets. Instead of using a

More information

Introductory Android Development

Introductory Android Development Introductory Android Development 152-163 Notes Quick Links & Text References Introduction Pages Layout Concepts Pages Layout Types Pages 35 37 XML Overview Pages Common Attributes Layout Height & Width

More information

CS 528 Mobile and Ubiquitous Computing Lecture 2a: Introduction to Android Programming. Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 2a: Introduction to Android Programming. Emmanuel Agu CS 528 Mobile and Ubiquitous Computing Lecture 2a: Introduction to Android Programming Emmanuel Agu Editting in Android Studio Recall: Editting Android Can edit apps in: Text View: edit XML directly Design

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

Android Layout Types

Android Layout Types Android Layout Types Android Linear Layout Android LinearLayout is a view group that aligns all children in either vertically or horizontally. android:divider - This is drawable to use as a vertical divider

More information

Let s take a display of HTC Desire smartphone as an example. Screen size = 3.7 inches, resolution = 800x480 pixels.

Let s take a display of HTC Desire smartphone as an example. Screen size = 3.7 inches, resolution = 800x480 pixels. Screens To begin with, here is some theory about screens. A screen has such physical properties as size and resolution. Screen size - a distance between two opposite corners of the screens, usually measured

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

CS 4518 Mobile and Ubiquitous Computing Lecture 2: Introduction to Android Programming. Emmanuel Agu

CS 4518 Mobile and Ubiquitous Computing Lecture 2: Introduction to Android Programming. Emmanuel Agu CS 4518 Mobile and Ubiquitous Computing Lecture 2: Introduction to Android Programming Emmanuel Agu Android Apps: Big Picture UI Design using XML UI design code (XML) separate from the program (Java) Why?

More information

User Interface: Layout. Asst. Prof. Dr. Kanda Runapongsa Saikaew Computer Engineering Khon Kaen University

User Interface: Layout. Asst. Prof. Dr. Kanda Runapongsa Saikaew Computer Engineering Khon Kaen University User Interface: Layout Asst. Prof. Dr. Kanda Runapongsa Saikaew Computer Engineering Khon Kaen University http://twitter.com/krunapon Agenda User Interface Declaring Layout Common Layouts User Interface

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

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

CS 528 Mobile and Ubiquitous Computing Lecture 2a: Android UI Design in XML + Examples. Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 2a: Android UI Design in XML + Examples. Emmanuel Agu CS 528 Mobile and Ubiquitous Computing Lecture 2a: Android UI Design in XML + Examples Emmanuel Agu Android UI Design in XML Recall: Files Hello World Android Project XML file used to design Android UI

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

MAD ASSIGNMENT NO 2. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept.

MAD ASSIGNMENT NO 2. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept. MAD ASSIGNMENT NO 2 Submitted by: Rehan Asghar BSSE 7 15126 AUGUST 25, 2017 SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept. Android Widgets There are given a lot of android widgets with simplified

More information

A view is a widget that has an appearance on screen. A view derives from the base class android.view.view.

A view is a widget that has an appearance on screen. A view derives from the base class android.view.view. LAYOUTS Views and ViewGroups An activity contains Views and ViewGroups. A view is a widget that has an appearance on screen. A view derives from the base class android.view.view. One or more views can

More information

(c) Dr Sonia Sail LAJMI College of Computer Sciences & IT (girl Section) 1

(c) Dr Sonia Sail LAJMI College of Computer Sciences & IT (girl Section) 1 Level 5: Baccalaureus in Computer Sciences CHAPTER 4: LAYOUTS AND VIEWS Dr. Sonia Saïd LAJMI PhD in Computer Sciences 1 Layout.xml 2 Computer Sciences & IT (girl Section) 1 Layout Requirements android:layout_width:

More information

Praktikum Entwicklung Mediensysteme. Implementing a User Interface

Praktikum Entwicklung Mediensysteme. Implementing a User Interface Praktikum Entwicklung Mediensysteme Implementing a User Interface Outline Introduction Programmatic vs. XML Layout Common Layout Objects Hooking into a Screen Element Listening for UI Notifications Applying

More information

CS378 -Mobile Computing. User Interface Basics

CS378 -Mobile Computing. User Interface Basics CS378 -Mobile Computing User Interface Basics User Interface Elements View Control ViewGroup Layout Widget (Compound Control) Many pre built Views Button, CheckBox, RadioButton TextView, EditText, ListView

More information

TextView Control. EditText Control. TextView Attributes. android:id - This is the ID which uniquely identifies the control.

TextView Control. EditText Control. TextView Attributes. android:id - This is the ID which uniquely identifies the control. A TextView displays text to the user. TextView Attributes TextView Control android:id - This is the ID which uniquely identifies the control. android:capitalize - If set, specifies that this TextView has

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

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

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

South Africa

South Africa South Africa 2013 Lecture 6: Layouts, Menus, Views http://aiti.mit.edu Create an Android Virtual Device Click the AVD Icon: Window -> AVD Manager -> New Name & start the virtual device (this may take a

More information

Mobile Application Development Android

Mobile Application Development Android Mobile Application Development Android Lecture 2 MTAT.03.262 Satish Srirama satish.srirama@ut.ee Android Lecture 1 -recap What is Android How to develop Android applications Run & debug the applications

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

Laying Out Controls in Containers

Laying Out Controls in Containers CHAPTER 3 Laying Out Controls in Containers A container is a view used to contain other views. Android offers a collection of view classes that act as containers for views. These container classes are

More information

MOBILE COMPUTING 1/20/18. How many of you. CSE 40814/60814 Spring have implemented a command-line user interface?

MOBILE COMPUTING 1/20/18. How many of you. CSE 40814/60814 Spring have implemented a command-line user interface? MOBILE COMPUTING CSE 40814/60814 Spring 2018 How many of you have implemented a command-line user interface? How many of you have implemented a graphical user interface? HTML/CSS Java Swing.NET Framework

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

CS371m - Mobile Computing. User Interface Basics

CS371m - Mobile Computing. User Interface Basics CS371m - Mobile Computing User Interface Basics Clicker Question Have you ever implemented a Graphical User Interface (GUI) as part of a program? A. Yes, in another class. B. Yes, at a job or internship.

More information

LECTURE 08 UI AND EVENT HANDLING

LECTURE 08 UI AND EVENT HANDLING MOBILE APPLICATION DEVELOPMENT LECTURE 08 UI AND EVENT HANDLING IMRAN IHSAN ASSISTANT PROFESSOR WWW.IMRANIHSAN.COM User Interface User Interface The Android Widget Toolbox 1. TextView 2. EditText 3. Spinner

More information

Chapter 8 Positioning with Layouts

Chapter 8 Positioning with Layouts Introduction to Android Application Development, Android Essentials, Fifth Edition Chapter 8 Positioning with Layouts Chapter 8 Overview Create user interfaces in Android by defining resource files or

More information

Interaction with Android

Interaction with Android Interaction with Android The Android program can output data by working with the xml files. The main use of the java files is to get some data, make decisions and change the output based on the results

More information

14.1 Overview of Android

14.1 Overview of Android 14.1 Overview of Android - Blackberry smart phone appeared in 2003 First widely used mobile access to the Web - Smart phone market now dominated by Android, iphone, and Windows Phone - Tablets are now

More information

04. Learn the basic widget. DKU-MUST Mobile ICT Education Center

04. Learn the basic widget. DKU-MUST Mobile ICT Education Center 04. Learn the basic widget DKU-MUST Mobile ICT Education Center Goal Understanding of the View and Inheritance of View. Learn how to use the default widget. Learn basic programming of the Android App.

More information

User Interface Development in Android Applications

User Interface Development in Android Applications ITU- FAO- DOA- TRCSL Training on Innovation & Application Development for E- Agriculture User Interface Development in Android Applications 11 th - 15 th December 2017 Peradeniya, Sri Lanka Shahryar Khan

More information

Sizing and Positioning

Sizing and Positioning CS 193A Layout This document is copyright (C) Marty Stepp and Stanford Computer Science. Licensed under Creative Commons Attribution 2.5 License. All rights reserved. Sizing and Positioning How does the

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

Stanislav Rost CSAIL, MIT

Stanislav Rost CSAIL, MIT Session 2: Lifecycles, GUI Stanislav Rost CSAIL, MIT The Plan 1 Activity lifecycle Service lifecycle 2 Selected GUI elements UI Layouts 3 Hands on assignment: RoboChat Application GUI Design Birth, death,

More information

TPCT s College of Engineering, Osmanabad. Laboratory Manual SDL-II. Mobile Application Development (Android) For. Third Year Students (CSE)

TPCT s College of Engineering, Osmanabad. Laboratory Manual SDL-II. Mobile Application Development (Android) For. Third Year Students (CSE) TPCT s College of Engineering, Osmanabad Laboratory Manual SDL-II Mobile Application Development (Android) For Third Year Students (CSE) Manual Prepared by Prof. Sujata A. Gaikwad Author COE, Osmanabad

More information

Programming Android UI. J. Serrat Software Design December 2017

Programming Android UI. J. Serrat Software Design December 2017 Programming Android UI J. Serrat Software Design December 2017 Preliminaries : Goals Introduce basic programming Android concepts Examine code for some simple examples Limited to those relevant for the

More information

Spring Lecture 4 Lecturer: Omid Jafarinezhad

Spring Lecture 4 Lecturer: Omid Jafarinezhad Mobile Programming Sharif University of Technology Spring 2016 - Lecture 4 Lecturer: Omid Jafarinezhad User Interface All user interface elements in an Android app are built using View and ViewGroup objects.

More information

Programming with Android: Application Resources. Dipartimento di Scienze dell Informazione Università di Bologna

Programming with Android: Application Resources. Dipartimento di Scienze dell Informazione Università di Bologna Programming with Android: Application Resources Luca Bedogni Marco Di Felice Dipartimento di Scienze dell Informazione Università di Bologna Outline What is a resource? Declaration of a resource Resource

More information

CS260 Intro to Java & Android 05.Android UI(Part I)

CS260 Intro to Java & Android 05.Android UI(Part I) CS260 Intro to Java & Android 05.Android UI(Part I) Winter 2018 Winter 2018 CS250 - Intro to Java & Android 1 User Interface UIs in Android are built using View and ViewGroup objects A View is the base

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

Comparative Study on Layout and Drawable Resource Behavior in Android for Supporting Multi Screen

Comparative Study on Layout and Drawable Resource Behavior in Android for Supporting Multi Screen International Journal of Innovative Research in Computer Science & Technology (IJIRCST) ISSN: 2347-5552, Volume 2, Issue 3, May - 2014 Comparative Study on Layout and Drawable Resource Behavior in Android

More information

Beginning Android 4 Application Development

Beginning Android 4 Application Development Beginning Android 4 Application Development Lee, Wei-Meng ISBN-13: 9781118199541 Table of Contents INTRODUCTION xxi CHAPTER 1: GETTING STARTED WITH ANDROID PROGRAMMING 1 What Is Android? 2 Android Versions

More information

Android Application Development

Android Application Development Android Application Development Octav Chipara What is Android A free, open source mobile platform A Linux-based, multiprocess, multithreaded OS Android is not a device or a product It s not even limited

More information

Android Programming (5 Days)

Android Programming (5 Days) www.peaklearningllc.com Android Programming (5 Days) Course Description Android is an open source platform for mobile computing. Applications are developed using familiar Java and Eclipse tools. This Android

More information

GUI Design for Android Applications

GUI Design for Android Applications GUI Design for Android Applications SE3A04 Tutorial Jason Jaskolka Department of Computing and Software Faculty of Engineering McMaster University Hamilton, Ontario, Canada jaskolj@mcmaster.ca November

More information

EECS 4443 Mobile User Interfaces. More About Layouts. Scott MacKenzie. York University. Overview (Review)

EECS 4443 Mobile User Interfaces. More About Layouts. Scott MacKenzie. York University. Overview (Review) EECS 4443 Mobile User Interfaces More About Layouts Scott MacKenzie York University Overview (Review) A layout defines the visual structure for a user interface, such as the UI for an activity or app widget

More information

CS260 Intro to Java & Android 05.Android UI(Part I)

CS260 Intro to Java & Android 05.Android UI(Part I) CS260 Intro to Java & Android 05.Android UI(Part I) Winter 2015 Winter 2015 CS250 - Intro to Java & Android 1 User Interface UIs in Android are built using View and ViewGroup objects A View is the base

More information

Basic UI elements: Android Buttons (Basics) Marco Ronchetti Università degli Studi di Trento

Basic UI elements: Android Buttons (Basics) Marco Ronchetti Università degli Studi di Trento Basic UI elements: Android Buttons (Basics) Marco Ronchetti Università degli Studi di Trento Let s work with the listener Button button = ; button.setonclicklistener(new.onclicklistener() { public void

More information

Mobila applikationer och trådlösa nät, HI1033, HT2013

Mobila applikationer och trådlösa nät, HI1033, HT2013 Mobila applikationer och trådlösa nät, HI1033, HT2013 Today: - User Interface basics - View components - Event driven applications and callbacks - Menu and Context Menu - ListView and Adapters - Android

More information

CS 528 Mobile and Ubiquitous Computing Lecture 2: Intro to Android Programming Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 2: Intro to Android Programming Emmanuel Agu CS 528 Mobile and Ubiquitous Computing Lecture 2: Intro to Android Programming Emmanuel Agu Students: Please Introduce Yourselves! Name Status: grad/undergrad, year Relevant background: e.g. coal miner

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

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

Basic GUI elements - exercises

Basic GUI elements - exercises Basic GUI elements - exercises https://developer.android.com/studio/index.html LIVE DEMO Please create a simple application, which will be used to calculate the area of basic geometric figures. To add

More information

EECS 4443 Mobile User Interfaces. More About Layouts. Scott MacKenzie. York University

EECS 4443 Mobile User Interfaces. More About Layouts. Scott MacKenzie. York University EECS 4443 Mobile User Interfaces More About Layouts Scott MacKenzie York University Overview (Review) A layout defines the visual structure for a user interface, such as the UI for an activity or app widget

More information

Mobila applikationer och trådlösa nät, HI1033, HT2012

Mobila applikationer och trådlösa nät, HI1033, HT2012 Mobila applikationer och trådlösa nät, HI1033, HT2012 Today: - User Interface basics - View components - Event driven applications and callbacks - Menu and Context Menu - ListView and Adapters - Android

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

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

MC Android Programming

MC Android Programming MC1921 - Android Programming Duration: 5 days Course Price: $3,395 Course Description Android is an open source platform for mobile computing. Applications are developed using familiar Java and Eclipse

More information

CS 528 Mobile and Ubiquitous Computing Lecture 2: Intro to Android Programming Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 2: Intro to Android Programming Emmanuel Agu CS 528 Mobile and Ubiquitous Computing Lecture 2: Intro to Android Programming Emmanuel Agu Android UI Tour Home Screen First screen after unlocking phone or hitting home button Includes favorites tray

More information

Mobile User Interfaces

Mobile User Interfaces Mobile User Interfaces CS 2046 Mobile Application Development Fall 2010 Announcements Next class = Lab session: Upson B7 Office Hours (starting 10/25): Me: MW 1:15-2:15 PM, Upson 360 Jae (TA): F 11:00

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

Required Core Java for Android application development

Required Core Java for Android application development Required Core Java for Android application development Introduction to Java Datatypes primitive data types non-primitive data types Variable declaration Operators Control flow statements Arrays and Enhanced

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

Views & View Events View Groups, AdapterViews & Layouts Menus & ActionBar Dialogs

Views & View Events View Groups, AdapterViews & Layouts Menus & ActionBar Dialogs Views & View Events View Groups, AdapterViews & Layouts Menus & ActionBar Dialogs Activities usually display a user interface Android provides many classes for constructing user interfaces Key building

More information

Mobile Programming Lecture 3. Resources, Selection, Activities, Intents

Mobile Programming Lecture 3. Resources, Selection, Activities, Intents Mobile Programming Lecture 3 Resources, Selection, Activities, Intents Lecture 2 Review What widget would you use to allow the user to enter a yes/no value a range of values from 1 to 100 What's the benefit

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

Android Basics. - Bhaumik Shukla Android Application STEALTH FLASH

Android Basics. - Bhaumik Shukla Android Application STEALTH FLASH Android Basics - Bhaumik Shukla Android Application Developer @ STEALTH FLASH Introduction to Android Android is a software stack for mobile devices that includes an operating system, middleware and key

More information

Programming with Android: System Architecture. Dipartimento di Scienze dell Informazione Università di Bologna

Programming with Android: System Architecture. Dipartimento di Scienze dell Informazione Università di Bologna Programming with Android: System Architecture Luca Bedogni Marco Di Felice Dipartimento di Scienze dell Informazione Università di Bologna Outline Android Architecture: An Overview Android Dalvik Java

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

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

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

Mobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator.

Mobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator. Simple Android Application for Native Calculator Aim: To develop a Simple Android Application for Native Calculator. Procedure: Creating a New project: Open Android Stdio and then click on File -> New

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

Chapter 2 Welcome App

Chapter 2 Welcome App 2.8 Internationalizing Your App 1 Chapter 2 Welcome App 2.1 Introduction a. Android Studio s layout editor enables you to build GUIs using drag-and-drop techniques. b. You can edit the GUI s XML directly.

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

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

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

Android Application Development 101. Jason Chen Google I/O 2008

Android Application Development 101. Jason Chen Google I/O 2008 Android Application Development 101 Jason Chen Google I/O 2008 Goal Get you an idea of how to start developing Android applications Introduce major Android application concepts Provide pointers for where

More information

Figure 2.10 demonstrates the creation of a new project named Chapter2 using the wizard.

Figure 2.10 demonstrates the creation of a new project named Chapter2 using the wizard. 44 CHAPTER 2 Android s development environment Figure 2.10 demonstrates the creation of a new project named Chapter2 using the wizard. TIP You ll want the package name of your applications to be unique

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

Android. Applications Activities Interface

Android. Applications Activities Interface Android Applications Activities Interface Applications Processes Usually each application, including all its components, runs in a single process; the Application object is always in memory Priorities

More information

Programming with Android: System Architecture. Dipartimento di Scienze dell Informazione Università di Bologna

Programming with Android: System Architecture. Dipartimento di Scienze dell Informazione Università di Bologna Programming with Android: System Architecture Luca Bedogni Marco Di Felice Dipartimento di Scienze dell Informazione Università di Bologna Outline Android Architecture: An Overview Android Dalvik Java

More information

Mobile and Ubiquitous Computing: Android Programming (part 3)

Mobile and Ubiquitous Computing: Android Programming (part 3) Mobile and Ubiquitous Computing: Android Programming (part 3) Master studies, Winter 2015/2016 Dr Veljko Pejović Veljko.Pejovic@fri.uni-lj.si Based on Programming Handheld Systems, Adam Porter, University

More information