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

Internship Report].pdf iiwmoosmsosmshkssmk
Internship Report].pdf iiwmoosmsosmshkssmkInternship Report].pdf iiwmoosmsosmshkssmk
Internship Report].pdf iiwmoosmsosmshkssmkSujalTamhane
 
Personal Brand Exploration ppt.- Ronnie Jones
Personal Brand  Exploration ppt.- Ronnie JonesPersonal Brand  Exploration ppt.- Ronnie Jones
Personal Brand Exploration ppt.- Ronnie Jonesjonesyde302
 
Call Girls Hoodi Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hoodi Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hoodi Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hoodi Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangaloreamitlee9823
 
Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...amitlee9823
 
reStartEvents 5:9 DC metro & Beyond V-Career Fair Employer Directory.pdf
reStartEvents 5:9 DC metro & Beyond V-Career Fair Employer Directory.pdfreStartEvents 5:9 DC metro & Beyond V-Career Fair Employer Directory.pdf
reStartEvents 5:9 DC metro & Beyond V-Career Fair Employer Directory.pdfKen Fuller
 
Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...
Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...
Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...poojakaurpk09
 
Call Girls Btm Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Btm Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Btm Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Btm Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...amitlee9823
 
Call Girls In Sarjapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Sarjapur Road ☎ 7737669865 🥵 Book Your One night StandCall Girls In Sarjapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Sarjapur Road ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Call Girls In Kengeri Satellite Town ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Kengeri Satellite Town ☎ 7737669865 🥵 Book Your One night StandCall Girls In Kengeri Satellite Town ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Kengeri Satellite Town ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Guide to a Winning Interview May 2024 for MCWN
Guide to a Winning Interview May 2024 for MCWNGuide to a Winning Interview May 2024 for MCWN
Guide to a Winning Interview May 2024 for MCWNBruce Bennett
 
Call Girls Jayanagar Just Call 👗 9155563397 👗 Top Class Call Girl Service Ban...
Call Girls Jayanagar Just Call 👗 9155563397 👗 Top Class Call Girl Service Ban...Call Girls Jayanagar Just Call 👗 9155563397 👗 Top Class Call Girl Service Ban...
Call Girls Jayanagar Just Call 👗 9155563397 👗 Top Class Call Girl Service Ban...only4webmaster01
 
TEST BANK For Evidence-Based Practice for Nurses Appraisal and Application of...
TEST BANK For Evidence-Based Practice for Nurses Appraisal and Application of...TEST BANK For Evidence-Based Practice for Nurses Appraisal and Application of...
TEST BANK For Evidence-Based Practice for Nurses Appraisal and Application of...robinsonayot
 
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangaloreamitlee9823
 
Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...
Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...
Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...amitlee9823
 
➥🔝 7737669865 🔝▻ Mirzapur Call-girls in Women Seeking Men 🔝Mirzapur🔝 Escor...
➥🔝 7737669865 🔝▻ Mirzapur Call-girls in Women Seeking Men  🔝Mirzapur🔝   Escor...➥🔝 7737669865 🔝▻ Mirzapur Call-girls in Women Seeking Men  🔝Mirzapur🔝   Escor...
➥🔝 7737669865 🔝▻ Mirzapur Call-girls in Women Seeking Men 🔝Mirzapur🔝 Escor...amitlee9823
 
Presentation for the country presentation
Presentation for the country presentationPresentation for the country presentation
Presentation for the country presentationjalal879
 
Personal Brand Exploration - Fernando Negron
Personal Brand Exploration - Fernando NegronPersonal Brand Exploration - Fernando Negron
Personal Brand Exploration - Fernando Negronnegronf24
 
Call Girls Bommanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Bommanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service ...Call Girls Bommanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Bommanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service ...amitlee9823
 
➥🔝 7737669865 🔝▻ Pallavaram Call-girls in Women Seeking Men 🔝Pallavaram🔝 E...
➥🔝 7737669865 🔝▻ Pallavaram Call-girls in Women Seeking Men  🔝Pallavaram🔝   E...➥🔝 7737669865 🔝▻ Pallavaram Call-girls in Women Seeking Men  🔝Pallavaram🔝   E...
➥🔝 7737669865 🔝▻ Pallavaram Call-girls in Women Seeking Men 🔝Pallavaram🔝 E...amitlee9823
 
Dubai Call Girls Kiki O525547819 Call Girls Dubai Koko
Dubai Call Girls Kiki O525547819 Call Girls Dubai KokoDubai Call Girls Kiki O525547819 Call Girls Dubai Koko
Dubai Call Girls Kiki O525547819 Call Girls Dubai Kokokojalkojal131
 

Recently uploaded (20)

Internship Report].pdf iiwmoosmsosmshkssmk
Internship Report].pdf iiwmoosmsosmshkssmkInternship Report].pdf iiwmoosmsosmshkssmk
Internship Report].pdf iiwmoosmsosmshkssmk
 
Personal Brand Exploration ppt.- Ronnie Jones
Personal Brand  Exploration ppt.- Ronnie JonesPersonal Brand  Exploration ppt.- Ronnie Jones
Personal Brand Exploration ppt.- Ronnie Jones
 
Call Girls Hoodi Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hoodi Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hoodi Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hoodi Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
 
reStartEvents 5:9 DC metro & Beyond V-Career Fair Employer Directory.pdf
reStartEvents 5:9 DC metro & Beyond V-Career Fair Employer Directory.pdfreStartEvents 5:9 DC metro & Beyond V-Career Fair Employer Directory.pdf
reStartEvents 5:9 DC metro & Beyond V-Career Fair Employer Directory.pdf
 
Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...
Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...
Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...
 
Call Girls Btm Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Btm Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Btm Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Btm Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
Call Girls In Sarjapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Sarjapur Road ☎ 7737669865 🥵 Book Your One night StandCall Girls In Sarjapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Sarjapur Road ☎ 7737669865 🥵 Book Your One night Stand
 
Call Girls In Kengeri Satellite Town ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Kengeri Satellite Town ☎ 7737669865 🥵 Book Your One night StandCall Girls In Kengeri Satellite Town ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Kengeri Satellite Town ☎ 7737669865 🥵 Book Your One night Stand
 
Guide to a Winning Interview May 2024 for MCWN
Guide to a Winning Interview May 2024 for MCWNGuide to a Winning Interview May 2024 for MCWN
Guide to a Winning Interview May 2024 for MCWN
 
Call Girls Jayanagar Just Call 👗 9155563397 👗 Top Class Call Girl Service Ban...
Call Girls Jayanagar Just Call 👗 9155563397 👗 Top Class Call Girl Service Ban...Call Girls Jayanagar Just Call 👗 9155563397 👗 Top Class Call Girl Service Ban...
Call Girls Jayanagar Just Call 👗 9155563397 👗 Top Class Call Girl Service Ban...
 
TEST BANK For Evidence-Based Practice for Nurses Appraisal and Application of...
TEST BANK For Evidence-Based Practice for Nurses Appraisal and Application of...TEST BANK For Evidence-Based Practice for Nurses Appraisal and Application of...
TEST BANK For Evidence-Based Practice for Nurses Appraisal and Application of...
 
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...
Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...
Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...
 
➥🔝 7737669865 🔝▻ Mirzapur Call-girls in Women Seeking Men 🔝Mirzapur🔝 Escor...
➥🔝 7737669865 🔝▻ Mirzapur Call-girls in Women Seeking Men  🔝Mirzapur🔝   Escor...➥🔝 7737669865 🔝▻ Mirzapur Call-girls in Women Seeking Men  🔝Mirzapur🔝   Escor...
➥🔝 7737669865 🔝▻ Mirzapur Call-girls in Women Seeking Men 🔝Mirzapur🔝 Escor...
 
Presentation for the country presentation
Presentation for the country presentationPresentation for the country presentation
Presentation for the country presentation
 
Personal Brand Exploration - Fernando Negron
Personal Brand Exploration - Fernando NegronPersonal Brand Exploration - Fernando Negron
Personal Brand Exploration - Fernando Negron
 
Call Girls Bommanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Bommanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service ...Call Girls Bommanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Bommanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
 
➥🔝 7737669865 🔝▻ Pallavaram Call-girls in Women Seeking Men 🔝Pallavaram🔝 E...
➥🔝 7737669865 🔝▻ Pallavaram Call-girls in Women Seeking Men  🔝Pallavaram🔝   E...➥🔝 7737669865 🔝▻ Pallavaram Call-girls in Women Seeking Men  🔝Pallavaram🔝   E...
➥🔝 7737669865 🔝▻ Pallavaram Call-girls in Women Seeking Men 🔝Pallavaram🔝 E...
 
Dubai Call Girls Kiki O525547819 Call Girls Dubai Koko
Dubai Call Girls Kiki O525547819 Call Girls Dubai KokoDubai Call Girls Kiki O525547819 Call Girls Dubai Koko
Dubai Call Girls Kiki O525547819 Call Girls Dubai Koko
 

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