SlideShare a Scribd company logo
1 of 12
Android
User Interface
Gaurav Mitra
User Interface1
Everything that a user sees and interacts with is classified under UI
► All elements built using View and ViewGroup
objects
) View: An object that draws
something on the screen
) ViewGroup: An invisible container
that holds other view objects to
define a particular layout
► View objects can be instantiated in code or
defined in XML layout files
► XML tag names correspond with Java class
name e.g.<TextView> corresponds with the
TextView widget
1http://developer.android.com/guide/topics/ui/overview.html.
COMP 2100/2500/6442 2/12
Layouts2
► A visual structure for a UI with two methods for declaration
► In XML layout files
) Well defined XML vocabulary corresponding to Widgets and Layouts
) Enables better separation of the presentation of the app from code that
controls behaviour
) Allows quick reconfiguration of UI elements without changing control code
) Easier to visualize structure of UI
) Possibly easier to debug
) Can create separate XML layouts for different screen orientations, sizes etc.
These layouts could be switched around in a dynamic fashion based on
screen conditions
► Instantiated in Java code at runtime:
) Create View and ViewGroup objects
) Change their properties programmatically.
) Difficult to separate presentation from control code
2http://developer.android.com/guide/topics/ui/declaring -layout.html.
COMP 2100/2500/6442 3/12
XML Layouts3
► Files must be placed in res/layout/filename.xml
► Filename used as resource ID i.e. R.layout.filename
► Each layout file must have exactly one root element which is either a View or
ViewGroup object
<? xml v e r s i o n =" 1 . 0 " encoding =" u t f - 8 "? >
< R e l a t i v e Layout x m ln s : a n d ro id =" h t t p : / / schemas. a n d ro id . com/ apk/ r e s / a n d ro id "
. . .
► UI elements have many attributes. Some attributes are common to all View objects
) ID: A unique string identifier specified in XML but is referenced as an integer
after compilation. XML format for specifying an ID is
andr oi d : i d=" @
+i d/ my _wi dg et "
andr oi d : i d=" @
andr oi d : i d/ empt y "
) @ - XML parser must parse and expand the rest of the ID string and identify it as an ID resource
) + - It is a new resource name that must be created/compiled and added to R.java
) Layout Width, Layout Height
► Declare widgets: Define in layout file with unique ID, then create instance of View
object and capture it from layout in Java code e.g. findViewById(R.id.my widget)
3 http://developer.android.com/guide/topics/ui/declaring -layout.html.
COMP 2100/2500/6442 4/12
XML Layout Syntax4
<? xml v e r s i o n =" 1 . 0 " encoding =" u t f - 8 "? >
<View Group x m ln s : a n d ro id =" h t t p : / / schemas. a n d ro id . com/ apk/ r e s / a n d ro id "
a n d ro id : id="@ [ + ] [ package : ] i d / resource_name "
a n d ro id : l a y o u t _ h e i g h t = [ " dimension " | " f i l l _ p a r e n t " | " wrap_content " ]
a n d ro id : la y o u t _ w id t h = [ " dimension " | " f i l l _ p a r e n t " | " wrap_content " ]
[ View Group - s p e c i f i c a t t r i b u t e s ] >
<View
a n d ro id : id="@ [ + ] [ package : ] i d / resource_name "
a n d ro id : l a y o u t _ h e i g h t = [ " dimension " | " f i l l _ p a r e n t " | " wrap_content " ]
a n d ro id : la y o u t _ w id t h = [ " dimension " | " f i l l _ p a r e n t " | " wrap_content " ]
[ View - s p e c i f i c a t t r i b u t e s ] >
< r eques t F oc us / >
</ Vi ew>
< Vi ewGr oup >
<Vi ew / >
</ Vi ewGr oup >
< i n c l u d e layout="@ l a y o u t / l a y o u t _ r e s o u r c e " / >
</ Vi ewGr oup >
► fill parent: Match dimension to parent
► wrap content: Set dimension to only size required to fit content
► <include>: Includes another layout file within this file
4 http://developer.android.com/guide/topics/resources/layout-resource.html.
COMP 2100/2500/6442 5/12
Layout Types5
► Static layouts: the widgets are usually
pre-defined
) Linear: Single horizontal or vertical row.
Automatic scrollbar if length of window
exceeds length of screen
) Relative: Specify child object locations
relative to each other
► Dynamic layouts: Widgets pulled from data
source such as an array or db query, using an
Adapter which converts data items to Views
that can be added to an AdapterView layout
) List View: Scrolling single column list
) Grid View: Scrolling grid of columns and
rows
► Possibleto nest layouts, but should ideally be
avoidedbecauseof performance issueswith
nested layouts. Flat hierarchy is better
5 http://developer.android.com/guide/topics/ui/declaring -layout.html.
COMP 2100/2500/6442 6/12
Input Controls6
► Button: Push-button that can be pressed
► Text Field: Editable text field.
AutoCompleteTextView available
► Checkbox: An on/off switch that can be
toggled. Used to provide options
► Radio Button: Like checkbox, but only one
option selectable
► Toggle Button: On/off button with indicator
► Spinner: Drop-down list from which one item
can be selected
► Picker: Dialog to scroll a set of values and
pick one. Used for time, date etc
6http://developer.android.com/guide/topics/ui/controls.html.
COMP 2100/2500/6442 7/12
Input Events7
► Capture events from users interaction with individual widgets or View objects
► Multiple event listeners (interface in View class which has single callback method)
provided. Listeners must be registered for individual View objects
) onClick(): User touches item or presses enter key when applicable
) onLongClick(): Similar to onClick, but user also holds touch
) onFocusChange(): User navigates onto or away from item
) onKey(): When focused, a hardware key is pressed or released
) onTouch(): Any touch event i.e. press, release, movement gesture etc
) onCreateContextMenu(): When context menu is created on long click
Button myButton = ( Button ) f i n d View B y I d ( R . i d . my_button ) ;
myButton . setOn C l i c k L i s t e n e r (
new View . OnC l i c k L i s t e n e r ( ) {
publ i c v oi d onCl i c k ( Vi ew v ) {
L og . v ( TAG, " But t on Pr es s ed " ) ;
}
}
) ;
7http://developer.android.com/guide/top ic s / u i/ u i - events.html.
COMP 2100/2500/6442 8/12
Menus8
► Standardized menus available from the Menu class. Three types of
menus:
) Options menu and app bar: Actions relevant to current activity such as
Search, Settings etc. For API 11 and higher, this is in the app bar at the top
of each app
) Contextual menu: Offers actions that affect a specific item or context frame
in the UI. Most often used for items in TextView, TextView layouts
) Floating Context Menu: Menu appears as a floating list or dialog
) Contextual Action Mode: Menu appears as an action bar at the top
) Popup menu: Anchored to a View in an overflow-style for actions that relate
to specific content
► Can be defined in XML or Java code
► Menu click events handled using listeners and callback methods such
as onOptionsItemSelected()
8http://developer.android.com/guide/topics/ui/menus.html.
COMP 2100/2500/6442 9/12
Dialogs9
► Small window that prompts user to
make a decision or enter additional info
► Should derive from the Dialog base
class without instantiating it directly
► Use one of the subclasses: AlertDialog,
DatePickerDialog, TimePickerDialog
9http://developer.android.com/guide/topics/ui/dialogs.html.
COMP 2100/2500/6442 10/12
Notifications10
► A message you can display to the user
outside of apps normal UI
► First appears as an icon in notification
area. User must open up notification
drawer to view it
► A Notification object must contain
) setSmallIcon(): A small icon
) setContentTitle(): A title
) setContentText(): Detail text
► Notification actions defined by using
Intent objects that start an Activity
10 http://developer.android.com/guide/topics/ui/notifiers/notifications.html .
COMP 2100/2500/6442 11/12
Toasts11
► Provides simple feedback about an
operation in a small popup
► Only fills amount of space required for
the message
► Current activity remains visible and
interactive during Toast display
► Instantiate a Toast object
11http://developer.android.com/guide/topics/ui/notifiers/toas ts.html.
COMP 2100/2500/6442 12/12

More Related Content

Similar to 08ui.pptx

01 09 - graphical user interface - basic widgets
01  09 - graphical user interface - basic widgets01  09 - graphical user interface - basic widgets
01 09 - graphical user interface - basic widgetsSiva Kumar reddy Vasipally
 
Lec005 android start_program
Lec005 android start_programLec005 android start_program
Lec005 android start_programEyad Almasri
 
Android Development for Beginners with Sample Project - Day 1
Android Development for Beginners with Sample Project - Day 1Android Development for Beginners with Sample Project - Day 1
Android Development for Beginners with Sample Project - Day 1Joemarie Amparo
 
Android Development Made Easy - With Sample Project
Android Development Made Easy - With Sample ProjectAndroid Development Made Easy - With Sample Project
Android Development Made Easy - With Sample ProjectJoemarie Amparo
 
Android Jumpstart Jfokus
Android Jumpstart JfokusAndroid Jumpstart Jfokus
Android Jumpstart JfokusLars Vogel
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorialAbid Khan
 
行動App開發管理實務 unit2
行動App開發管理實務 unit2行動App開發管理實務 unit2
行動App開發管理實務 unit2Xavier Yin
 
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...Ted Chien
 
Building a simple user interface lesson2
Building a simple user interface lesson2Building a simple user interface lesson2
Building a simple user interface lesson2Kalluri Vinay Reddy
 
Android apps development
Android apps developmentAndroid apps development
Android apps developmentMonir Zzaman
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android AppsGil Irizarry
 
Android Tutorial
Android TutorialAndroid Tutorial
Android TutorialFun2Do Labs
 
Android ui layout
Android ui layoutAndroid ui layout
Android ui layoutKrazy Koder
 
Android Development project
Android Development projectAndroid Development project
Android Development projectMinhaj Kazi
 
Developing your first application using FI-WARE
Developing your first application using FI-WAREDeveloping your first application using FI-WARE
Developing your first application using FI-WAREFermin Galan
 
Quick Intro to Android Development
Quick Intro to Android DevelopmentQuick Intro to Android Development
Quick Intro to Android DevelopmentJussi Pohjolainen
 

Similar to 08ui.pptx (20)

01 09 - graphical user interface - basic widgets
01  09 - graphical user interface - basic widgets01  09 - graphical user interface - basic widgets
01 09 - graphical user interface - basic widgets
 
Android
AndroidAndroid
Android
 
Android programming basics
Android programming basicsAndroid programming basics
Android programming basics
 
Lec005 android start_program
Lec005 android start_programLec005 android start_program
Lec005 android start_program
 
Android Development for Beginners with Sample Project - Day 1
Android Development for Beginners with Sample Project - Day 1Android Development for Beginners with Sample Project - Day 1
Android Development for Beginners with Sample Project - Day 1
 
Android Development Made Easy - With Sample Project
Android Development Made Easy - With Sample ProjectAndroid Development Made Easy - With Sample Project
Android Development Made Easy - With Sample Project
 
Android Jumpstart Jfokus
Android Jumpstart JfokusAndroid Jumpstart Jfokus
Android Jumpstart Jfokus
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Android by Swecha
Android by SwechaAndroid by Swecha
Android by Swecha
 
行動App開發管理實務 unit2
行動App開發管理實務 unit2行動App開發管理實務 unit2
行動App開發管理實務 unit2
 
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
 
Building a simple user interface lesson2
Building a simple user interface lesson2Building a simple user interface lesson2
Building a simple user interface lesson2
 
Android apps development
Android apps developmentAndroid apps development
Android apps development
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android Apps
 
Android Tutorial
Android TutorialAndroid Tutorial
Android Tutorial
 
Android ui layout
Android ui layoutAndroid ui layout
Android ui layout
 
Android Development project
Android Development projectAndroid Development project
Android Development project
 
Developing your first application using FI-WARE
Developing your first application using FI-WAREDeveloping your first application using FI-WARE
Developing your first application using FI-WARE
 
Ios - Introduction to platform & SDK
Ios - Introduction to platform & SDKIos - Introduction to platform & SDK
Ios - Introduction to platform & SDK
 
Quick Intro to Android Development
Quick Intro to Android DevelopmentQuick Intro to Android Development
Quick Intro to Android Development
 

More from KabadaSori

Spirit of silence and speak.pptx
Spirit of silence and speak.pptxSpirit of silence and speak.pptx
Spirit of silence and speak.pptxKabadaSori
 
Speaking in the Spirit.pptx
Speaking in the Spirit.pptxSpeaking in the Spirit.pptx
Speaking in the Spirit.pptxKabadaSori
 
1 Fundamentals of EDP (2).pptx
1 Fundamentals of EDP (2).pptx1 Fundamentals of EDP (2).pptx
1 Fundamentals of EDP (2).pptxKabadaSori
 
compsec_incomplete_mediation.pptx
compsec_incomplete_mediation.pptxcompsec_incomplete_mediation.pptx
compsec_incomplete_mediation.pptxKabadaSori
 
communicationpresentation-151125220210-lva1-app6891.pdf
communicationpresentation-151125220210-lva1-app6891.pdfcommunicationpresentation-151125220210-lva1-app6891.pdf
communicationpresentation-151125220210-lva1-app6891.pdfKabadaSori
 
chapter 1.pptx
chapter 1.pptxchapter 1.pptx
chapter 1.pptxKabadaSori
 

More from KabadaSori (7)

Spirit of silence and speak.pptx
Spirit of silence and speak.pptxSpirit of silence and speak.pptx
Spirit of silence and speak.pptx
 
Speaking in the Spirit.pptx
Speaking in the Spirit.pptxSpeaking in the Spirit.pptx
Speaking in the Spirit.pptx
 
1 Fundamentals of EDP (2).pptx
1 Fundamentals of EDP (2).pptx1 Fundamentals of EDP (2).pptx
1 Fundamentals of EDP (2).pptx
 
compsec_incomplete_mediation.pptx
compsec_incomplete_mediation.pptxcompsec_incomplete_mediation.pptx
compsec_incomplete_mediation.pptx
 
communicationpresentation-151125220210-lva1-app6891.pdf
communicationpresentation-151125220210-lva1-app6891.pdfcommunicationpresentation-151125220210-lva1-app6891.pdf
communicationpresentation-151125220210-lva1-app6891.pdf
 
cellular.ppt
cellular.pptcellular.ppt
cellular.ppt
 
chapter 1.pptx
chapter 1.pptxchapter 1.pptx
chapter 1.pptx
 

Recently uploaded

VIP Call Girls Service Cuttack Aishwarya 8250192130 Independent Escort Servic...
VIP Call Girls Service Cuttack Aishwarya 8250192130 Independent Escort Servic...VIP Call Girls Service Cuttack Aishwarya 8250192130 Independent Escort Servic...
VIP Call Girls Service Cuttack Aishwarya 8250192130 Independent Escort Servic...Suhani Kapoor
 
Full Masii Russian Call Girls In Dwarka (Delhi) 9711199012 💋✔💕😘We are availab...
Full Masii Russian Call Girls In Dwarka (Delhi) 9711199012 💋✔💕😘We are availab...Full Masii Russian Call Girls In Dwarka (Delhi) 9711199012 💋✔💕😘We are availab...
Full Masii Russian Call Girls In Dwarka (Delhi) 9711199012 💋✔💕😘We are availab...shivangimorya083
 
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service Bhiwandi
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service BhiwandiVIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service Bhiwandi
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service BhiwandiSuhani Kapoor
 
Delhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
PM Job Search Council Info Session - PMI Silver Spring Chapter
PM Job Search Council Info Session - PMI Silver Spring ChapterPM Job Search Council Info Session - PMI Silver Spring Chapter
PM Job Search Council Info Session - PMI Silver Spring ChapterHector Del Castillo, CPM, CPMM
 
Low Rate Call Girls Gorakhpur Anika 8250192130 Independent Escort Service Gor...
Low Rate Call Girls Gorakhpur Anika 8250192130 Independent Escort Service Gor...Low Rate Call Girls Gorakhpur Anika 8250192130 Independent Escort Service Gor...
Low Rate Call Girls Gorakhpur Anika 8250192130 Independent Escort Service Gor...Suhani Kapoor
 
Delhi Call Girls Preet Vihar 9711199171 ☎✔👌✔ Whatsapp Body to body massage wi...
Delhi Call Girls Preet Vihar 9711199171 ☎✔👌✔ Whatsapp Body to body massage wi...Delhi Call Girls Preet Vihar 9711199171 ☎✔👌✔ Whatsapp Body to body massage wi...
Delhi Call Girls Preet Vihar 9711199171 ☎✔👌✔ Whatsapp Body to body massage wi...shivangimorya083
 
CALL ON ➥8923113531 🔝Call Girls Husainganj Lucknow best Female service 🧳
CALL ON ➥8923113531 🔝Call Girls Husainganj Lucknow best Female service  🧳CALL ON ➥8923113531 🔝Call Girls Husainganj Lucknow best Female service  🧳
CALL ON ➥8923113531 🔝Call Girls Husainganj Lucknow best Female service 🧳anilsa9823
 
VIP Russian Call Girls Amravati Chhaya 8250192130 Independent Escort Service ...
VIP Russian Call Girls Amravati Chhaya 8250192130 Independent Escort Service ...VIP Russian Call Girls Amravati Chhaya 8250192130 Independent Escort Service ...
VIP Russian Call Girls Amravati Chhaya 8250192130 Independent Escort Service ...Suhani Kapoor
 
Business Development and Product Strategy for a SME named SARL based in Leban...
Business Development and Product Strategy for a SME named SARL based in Leban...Business Development and Product Strategy for a SME named SARL based in Leban...
Business Development and Product Strategy for a SME named SARL based in Leban...Soham Mondal
 
VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...
VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...
VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...Suhani Kapoor
 
Delhi Call Girls In Atta Market 9711199012 Book Your One night Stand Call Girls
Delhi Call Girls In Atta Market 9711199012 Book Your One night Stand Call GirlsDelhi Call Girls In Atta Market 9711199012 Book Your One night Stand Call Girls
Delhi Call Girls In Atta Market 9711199012 Book Your One night Stand Call Girlsshivangimorya083
 
Notes of bca Question paper for exams and tests
Notes of bca Question paper for exams and testsNotes of bca Question paper for exams and tests
Notes of bca Question paper for exams and testspriyanshukumar97908
 
Call Girls Mukherjee Nagar Delhi reach out to us at ☎ 9711199012
Call Girls Mukherjee Nagar Delhi reach out to us at ☎ 9711199012Call Girls Mukherjee Nagar Delhi reach out to us at ☎ 9711199012
Call Girls Mukherjee Nagar Delhi reach out to us at ☎ 9711199012rehmti665
 
Delhi Call Girls South Ex 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls South Ex 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls South Ex 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls South Ex 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...Suhani Kapoor
 
VIP Call Girl Bhilai Aashi 8250192130 Independent Escort Service Bhilai
VIP Call Girl Bhilai Aashi 8250192130 Independent Escort Service BhilaiVIP Call Girl Bhilai Aashi 8250192130 Independent Escort Service Bhilai
VIP Call Girl Bhilai Aashi 8250192130 Independent Escort Service BhilaiSuhani Kapoor
 
do's and don'ts in Telephone Interview of Job
do's and don'ts in Telephone Interview of Jobdo's and don'ts in Telephone Interview of Job
do's and don'ts in Telephone Interview of JobRemote DBA Services
 
Dark Dubai Call Girls O525547819 Skin Call Girls Dubai
Dark Dubai Call Girls O525547819 Skin Call Girls DubaiDark Dubai Call Girls O525547819 Skin Call Girls Dubai
Dark Dubai Call Girls O525547819 Skin Call Girls Dubaikojalkojal131
 

Recently uploaded (20)

VIP Call Girls Service Cuttack Aishwarya 8250192130 Independent Escort Servic...
VIP Call Girls Service Cuttack Aishwarya 8250192130 Independent Escort Servic...VIP Call Girls Service Cuttack Aishwarya 8250192130 Independent Escort Servic...
VIP Call Girls Service Cuttack Aishwarya 8250192130 Independent Escort Servic...
 
Full Masii Russian Call Girls In Dwarka (Delhi) 9711199012 💋✔💕😘We are availab...
Full Masii Russian Call Girls In Dwarka (Delhi) 9711199012 💋✔💕😘We are availab...Full Masii Russian Call Girls In Dwarka (Delhi) 9711199012 💋✔💕😘We are availab...
Full Masii Russian Call Girls In Dwarka (Delhi) 9711199012 💋✔💕😘We are availab...
 
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service Bhiwandi
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service BhiwandiVIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service Bhiwandi
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service Bhiwandi
 
Delhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
PM Job Search Council Info Session - PMI Silver Spring Chapter
PM Job Search Council Info Session - PMI Silver Spring ChapterPM Job Search Council Info Session - PMI Silver Spring Chapter
PM Job Search Council Info Session - PMI Silver Spring Chapter
 
Low Rate Call Girls Gorakhpur Anika 8250192130 Independent Escort Service Gor...
Low Rate Call Girls Gorakhpur Anika 8250192130 Independent Escort Service Gor...Low Rate Call Girls Gorakhpur Anika 8250192130 Independent Escort Service Gor...
Low Rate Call Girls Gorakhpur Anika 8250192130 Independent Escort Service Gor...
 
Delhi Call Girls Preet Vihar 9711199171 ☎✔👌✔ Whatsapp Body to body massage wi...
Delhi Call Girls Preet Vihar 9711199171 ☎✔👌✔ Whatsapp Body to body massage wi...Delhi Call Girls Preet Vihar 9711199171 ☎✔👌✔ Whatsapp Body to body massage wi...
Delhi Call Girls Preet Vihar 9711199171 ☎✔👌✔ Whatsapp Body to body massage wi...
 
CALL ON ➥8923113531 🔝Call Girls Husainganj Lucknow best Female service 🧳
CALL ON ➥8923113531 🔝Call Girls Husainganj Lucknow best Female service  🧳CALL ON ➥8923113531 🔝Call Girls Husainganj Lucknow best Female service  🧳
CALL ON ➥8923113531 🔝Call Girls Husainganj Lucknow best Female service 🧳
 
VIP Russian Call Girls Amravati Chhaya 8250192130 Independent Escort Service ...
VIP Russian Call Girls Amravati Chhaya 8250192130 Independent Escort Service ...VIP Russian Call Girls Amravati Chhaya 8250192130 Independent Escort Service ...
VIP Russian Call Girls Amravati Chhaya 8250192130 Independent Escort Service ...
 
Business Development and Product Strategy for a SME named SARL based in Leban...
Business Development and Product Strategy for a SME named SARL based in Leban...Business Development and Product Strategy for a SME named SARL based in Leban...
Business Development and Product Strategy for a SME named SARL based in Leban...
 
VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...
VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...
VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...
 
Delhi Call Girls In Atta Market 9711199012 Book Your One night Stand Call Girls
Delhi Call Girls In Atta Market 9711199012 Book Your One night Stand Call GirlsDelhi Call Girls In Atta Market 9711199012 Book Your One night Stand Call Girls
Delhi Call Girls In Atta Market 9711199012 Book Your One night Stand Call Girls
 
Notes of bca Question paper for exams and tests
Notes of bca Question paper for exams and testsNotes of bca Question paper for exams and tests
Notes of bca Question paper for exams and tests
 
Call Girls In Prashant Vihar꧁❤ 🔝 9953056974🔝❤꧂ Escort ServiCe
Call Girls In Prashant Vihar꧁❤ 🔝 9953056974🔝❤꧂ Escort ServiCeCall Girls In Prashant Vihar꧁❤ 🔝 9953056974🔝❤꧂ Escort ServiCe
Call Girls In Prashant Vihar꧁❤ 🔝 9953056974🔝❤꧂ Escort ServiCe
 
Call Girls Mukherjee Nagar Delhi reach out to us at ☎ 9711199012
Call Girls Mukherjee Nagar Delhi reach out to us at ☎ 9711199012Call Girls Mukherjee Nagar Delhi reach out to us at ☎ 9711199012
Call Girls Mukherjee Nagar Delhi reach out to us at ☎ 9711199012
 
Delhi Call Girls South Ex 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls South Ex 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls South Ex 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls South Ex 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...
 
VIP Call Girl Bhilai Aashi 8250192130 Independent Escort Service Bhilai
VIP Call Girl Bhilai Aashi 8250192130 Independent Escort Service BhilaiVIP Call Girl Bhilai Aashi 8250192130 Independent Escort Service Bhilai
VIP Call Girl Bhilai Aashi 8250192130 Independent Escort Service Bhilai
 
do's and don'ts in Telephone Interview of Job
do's and don'ts in Telephone Interview of Jobdo's and don'ts in Telephone Interview of Job
do's and don'ts in Telephone Interview of Job
 
Dark Dubai Call Girls O525547819 Skin Call Girls Dubai
Dark Dubai Call Girls O525547819 Skin Call Girls DubaiDark Dubai Call Girls O525547819 Skin Call Girls Dubai
Dark Dubai Call Girls O525547819 Skin Call Girls Dubai
 

08ui.pptx

  • 2. User Interface1 Everything that a user sees and interacts with is classified under UI ► All elements built using View and ViewGroup objects ) View: An object that draws something on the screen ) ViewGroup: An invisible container that holds other view objects to define a particular layout ► View objects can be instantiated in code or defined in XML layout files ► XML tag names correspond with Java class name e.g.<TextView> corresponds with the TextView widget 1http://developer.android.com/guide/topics/ui/overview.html. COMP 2100/2500/6442 2/12
  • 3. Layouts2 ► A visual structure for a UI with two methods for declaration ► In XML layout files ) Well defined XML vocabulary corresponding to Widgets and Layouts ) Enables better separation of the presentation of the app from code that controls behaviour ) Allows quick reconfiguration of UI elements without changing control code ) Easier to visualize structure of UI ) Possibly easier to debug ) Can create separate XML layouts for different screen orientations, sizes etc. These layouts could be switched around in a dynamic fashion based on screen conditions ► Instantiated in Java code at runtime: ) Create View and ViewGroup objects ) Change their properties programmatically. ) Difficult to separate presentation from control code 2http://developer.android.com/guide/topics/ui/declaring -layout.html. COMP 2100/2500/6442 3/12
  • 4. XML Layouts3 ► Files must be placed in res/layout/filename.xml ► Filename used as resource ID i.e. R.layout.filename ► Each layout file must have exactly one root element which is either a View or ViewGroup object <? xml v e r s i o n =" 1 . 0 " encoding =" u t f - 8 "? > < R e l a t i v e Layout x m ln s : a n d ro id =" h t t p : / / schemas. a n d ro id . com/ apk/ r e s / a n d ro id " . . . ► UI elements have many attributes. Some attributes are common to all View objects ) ID: A unique string identifier specified in XML but is referenced as an integer after compilation. XML format for specifying an ID is andr oi d : i d=" @ +i d/ my _wi dg et " andr oi d : i d=" @ andr oi d : i d/ empt y " ) @ - XML parser must parse and expand the rest of the ID string and identify it as an ID resource ) + - It is a new resource name that must be created/compiled and added to R.java ) Layout Width, Layout Height ► Declare widgets: Define in layout file with unique ID, then create instance of View object and capture it from layout in Java code e.g. findViewById(R.id.my widget) 3 http://developer.android.com/guide/topics/ui/declaring -layout.html. COMP 2100/2500/6442 4/12
  • 5. XML Layout Syntax4 <? xml v e r s i o n =" 1 . 0 " encoding =" u t f - 8 "? > <View Group x m ln s : a n d ro id =" h t t p : / / schemas. a n d ro id . com/ apk/ r e s / a n d ro id " a n d ro id : id="@ [ + ] [ package : ] i d / resource_name " a n d ro id : l a y o u t _ h e i g h t = [ " dimension " | " f i l l _ p a r e n t " | " wrap_content " ] a n d ro id : la y o u t _ w id t h = [ " dimension " | " f i l l _ p a r e n t " | " wrap_content " ] [ View Group - s p e c i f i c a t t r i b u t e s ] > <View a n d ro id : id="@ [ + ] [ package : ] i d / resource_name " a n d ro id : l a y o u t _ h e i g h t = [ " dimension " | " f i l l _ p a r e n t " | " wrap_content " ] a n d ro id : la y o u t _ w id t h = [ " dimension " | " f i l l _ p a r e n t " | " wrap_content " ] [ View - s p e c i f i c a t t r i b u t e s ] > < r eques t F oc us / > </ Vi ew> < Vi ewGr oup > <Vi ew / > </ Vi ewGr oup > < i n c l u d e layout="@ l a y o u t / l a y o u t _ r e s o u r c e " / > </ Vi ewGr oup > ► fill parent: Match dimension to parent ► wrap content: Set dimension to only size required to fit content ► <include>: Includes another layout file within this file 4 http://developer.android.com/guide/topics/resources/layout-resource.html. COMP 2100/2500/6442 5/12
  • 6. Layout Types5 ► Static layouts: the widgets are usually pre-defined ) Linear: Single horizontal or vertical row. Automatic scrollbar if length of window exceeds length of screen ) Relative: Specify child object locations relative to each other ► Dynamic layouts: Widgets pulled from data source such as an array or db query, using an Adapter which converts data items to Views that can be added to an AdapterView layout ) List View: Scrolling single column list ) Grid View: Scrolling grid of columns and rows ► Possibleto nest layouts, but should ideally be avoidedbecauseof performance issueswith nested layouts. Flat hierarchy is better 5 http://developer.android.com/guide/topics/ui/declaring -layout.html. COMP 2100/2500/6442 6/12
  • 7. Input Controls6 ► Button: Push-button that can be pressed ► Text Field: Editable text field. AutoCompleteTextView available ► Checkbox: An on/off switch that can be toggled. Used to provide options ► Radio Button: Like checkbox, but only one option selectable ► Toggle Button: On/off button with indicator ► Spinner: Drop-down list from which one item can be selected ► Picker: Dialog to scroll a set of values and pick one. Used for time, date etc 6http://developer.android.com/guide/topics/ui/controls.html. COMP 2100/2500/6442 7/12
  • 8. Input Events7 ► Capture events from users interaction with individual widgets or View objects ► Multiple event listeners (interface in View class which has single callback method) provided. Listeners must be registered for individual View objects ) onClick(): User touches item or presses enter key when applicable ) onLongClick(): Similar to onClick, but user also holds touch ) onFocusChange(): User navigates onto or away from item ) onKey(): When focused, a hardware key is pressed or released ) onTouch(): Any touch event i.e. press, release, movement gesture etc ) onCreateContextMenu(): When context menu is created on long click Button myButton = ( Button ) f i n d View B y I d ( R . i d . my_button ) ; myButton . setOn C l i c k L i s t e n e r ( new View . OnC l i c k L i s t e n e r ( ) { publ i c v oi d onCl i c k ( Vi ew v ) { L og . v ( TAG, " But t on Pr es s ed " ) ; } } ) ; 7http://developer.android.com/guide/top ic s / u i/ u i - events.html. COMP 2100/2500/6442 8/12
  • 9. Menus8 ► Standardized menus available from the Menu class. Three types of menus: ) Options menu and app bar: Actions relevant to current activity such as Search, Settings etc. For API 11 and higher, this is in the app bar at the top of each app ) Contextual menu: Offers actions that affect a specific item or context frame in the UI. Most often used for items in TextView, TextView layouts ) Floating Context Menu: Menu appears as a floating list or dialog ) Contextual Action Mode: Menu appears as an action bar at the top ) Popup menu: Anchored to a View in an overflow-style for actions that relate to specific content ► Can be defined in XML or Java code ► Menu click events handled using listeners and callback methods such as onOptionsItemSelected() 8http://developer.android.com/guide/topics/ui/menus.html. COMP 2100/2500/6442 9/12
  • 10. Dialogs9 ► Small window that prompts user to make a decision or enter additional info ► Should derive from the Dialog base class without instantiating it directly ► Use one of the subclasses: AlertDialog, DatePickerDialog, TimePickerDialog 9http://developer.android.com/guide/topics/ui/dialogs.html. COMP 2100/2500/6442 10/12
  • 11. Notifications10 ► A message you can display to the user outside of apps normal UI ► First appears as an icon in notification area. User must open up notification drawer to view it ► A Notification object must contain ) setSmallIcon(): A small icon ) setContentTitle(): A title ) setContentText(): Detail text ► Notification actions defined by using Intent objects that start an Activity 10 http://developer.android.com/guide/topics/ui/notifiers/notifications.html . COMP 2100/2500/6442 11/12
  • 12. Toasts11 ► Provides simple feedback about an operation in a small popup ► Only fills amount of space required for the message ► Current activity remains visible and interactive during Toast display ► Instantiate a Toast object 11http://developer.android.com/guide/topics/ui/notifiers/toas ts.html. COMP 2100/2500/6442 12/12