SlideShare una empresa de Scribd logo
1 de 44
Ch4. Creating User
     Interface
        Browny
      10, May, 2011
Outline


• Introducing Views
• Introducing Layouts
• Creating New Views
• Drawable Resources
• Creating and Using Menus
Terminology

• View
  ‣                                                          ,	
        	
  UI	
  controls	
  
             	
  layout	
  classes	
            	
  View	
              ,	
  
       	
  control	
           	
  widget	
  (not	
  home	
  screen	
  or	
  App	
  
      Widgets)

• View Groups
  ‣   View	
              	
  extension,	
                           	
  child	
  Views

• Activities
  ‣                  	
  user	
  interface,	
             	
  View	
  assign	
                   	
  
      Ac>vity
Creating Activity with Views(1/2)


• Activity                 user interface
  ‣   Call	
  setContentView,	
  passing	
  in	
  the	
  View	
  
      instance	
   	
  layout	
  resources	
  (layout	
  resource	
  ID)
  ‣   Almost	
  always	
  use	
  in	
  onCreate	
  handler

• Get references to the Views used
  within a layout with the findViewById
  method
Creating Activity with Views(2/2)
        Inflating an Activity layout




        Creating a UI layout in code
The Android Widget Toolbox

• Android supplies a toolbox of standard
  Views to help you create simple
  interfaces
• TextView, EditText, ListView, Spinner,
  Button, CheckBox, RadioButton,
  ViewFlipper, QuickContactBadge
   http://developer.android.com/guide/tutorials/views/index.html
Layouts

• Layout managers (layouts) are
  extensions of the ViewGroup class
  used to position child controls for
  your UI
• The Android SDK includes some
  simple layouts to help you construct
  your UI
       http://developer.android.com/guide/topics/ui/
Using Layouts


• Preferred way
 ‣   Implement	
  layouts	
  by	
  using	
  XML	
  as	
  external	
  
     resources

• A simple layout that places a TextView
  above an EditText control using a
  vertical LinearLayout
Simple Linear Layout in XML
Simple LinearLayout in Code
Optimizing Layouts(1/2)


• Inflating layouts into your Activities is
  an expensive process
• Good practice
 ‣   Keep	
  your	
  layouts	
  as	
  simple	
  as	
  possible
 ‣   Avoid	
  to	
  inflate	
  an	
  en>rely	
  new	
  layout	
  for	
  small	
  
     changes	
  to	
  an	
  exis>ng	
  one
Optimizing Layouts(2/2)

• Avoid unnecessary nesting (Don’t put
  one layout within another unless it is
  necessary)
• Avoid using too many Views
• Avoid deep nesting (It’s good practice to
  restrict nesting to fewer than 10 levels)
• Android SDK includes the layoutopt
  command line tool
Creating New Views

• Modify or Extend (appearance and/or
  behavior) an existing control
• Combine Views to create atomic,
  reusable controls (leverage the
  functionality of several interconnected
  Views)
• Create an entirely new control
Modifying Existing Views



• Create a new class that extends an
  existing control
• To override the appearance (onDraw)
• To override behavior (onKeyDown)
Creating Compound Controls

• Create compound controls by
  extending a ViewGroup (usually a layout)
• Choose the layout class that’s most
  suitable for positioning the child
  controls, and extend it
Compound View: Using an External
       Resource(1/3)
Compound View: Using an External
       Resource(2/3)



• To use this layout for your new View,
  override the View’s constructor to
  inflate the layout resource using the
  inflate method from the LayoutInflate
  system service
Compound View: Using an External
       Resource(3/3)
Compound View: in code
Hook up the event handlers for each
          child control
Creating Custom Views

• Extend either the View (lightweight
  solution) or SurfaceView classes (supports
  drawing from a background thread and
  using openGL for 3D graphics)
• The View class provides a Canvas object
  with a series of draw methods and Paint
  classes. Use them to create a visual
  interface with bitmaps and raster
  graphics
Creating a New Visual Interface(1/2)



 • The base View class presents a
   distinctly empty 100-pixel-by-100-
   pixel square
 • You need to override the onMeasure
   and onDraw methods to change it
Creating a New Visual Interface(2/2)
Drawing Your Control(1/3)

• Android provides a variety of tools to
  help draw your design on the Canvas
  using various Paint objects
• The Canvas class includes helper
  methods for drawing primitive 2D
  objects including circles, lines, etc.
• Also supports transformations that let
  you rotate, translate (move), and scale
  (resize) the Canvas while you draw on it
Drawing Your Control(2/3)

• Any object created in your onDraw
  method will be created and destroyed
  every time the screen refreshes (
    )
• Improve efficiency by making as many
  of these objects (particularly instances
  of Paint and Drawable) class-scoped
  and by moving their creation into the
  constructor
Drawing Your Control(3/3)
Sizing Your Control(1/3)

• The onMeasure method is called when
  the control’s parent is laying out its
  child controls
 ‣   It	
  asks	
  the	
  ques>on	
  ‘‘How	
  much	
  space	
  will	
  you	
  
     use?’’	
  and	
  passes	
  in	
  two	
  parameters:	
  
     widthMeasureSpec	
  and	
  heightMeasureSpec

• Rather than return a result, you pass
  the View’s height and width into the
  setMeasuredDimension method
Sizing Your Control (3/3)

• Before widthMeasureSpec and
  heightMeasureSpec can be used, they first
  need to be decoded using the static
  getMode and getSize methods from the
  MeasureSpec class
• Depending on the mode value, the size
  represents either the maximum space
  available for the control (AT_MOST), or
  the exact size that your control will
  occupy (EXACTLY)
Handling User Interaction Events
             (1/2)

• Android exposes several virtual event
  handlers that let you react to user
  input
 ‣   onKeyDown	
  (D-­‐pad,	
  keyboard,	
  hang-­‐up,	
  call,	
  
     back,	
  and	
  camera	
  buPons)
 ‣   onKeyUp
 ‣   onTrackballEvent
 ‣   onTouchEvent
Handling User Interaction Events
             (2/2)
Using Custom Controls

                 In Code




                 In XML
Drawable Resources


• Introduce several new types of
  Drawables resources
• Show how to use these resources to
  create user interfaces that are
  independent of screen size and
  resolution
Shapes, Colors, and Gradients

•   Android includes a number of simple Drawable
    resource types that can be defined entirely in
    XML
    ‣   ColorDrawable,	
  ShapeDrawable,	
  and	
  GradientDrawable	
  
        classes
    ‣   Composite	
  Drawables	
  (Transforma>ve	
  Drawables,	
  Layer	
  
        Drawable,	
  State	
  List	
  Drawables,	
  Level	
  List	
  Drawables)
    ‣   NinePatch	
  Drawable

•   These resources are stored in the
    res/drawable folder and can then be identified in
    code by their lowercase XML filenames
Resolution and Density
             Independence


• The resource directory qualifiers
 ‣   Store	
  alterna>ve	
  assets	
  and	
  layouts	
  for	
  different	
  
     screen	
  configura>ons	
  

• The manifest elements
 ‣   Limit	
  the	
  screen	
  sizes	
  your	
  applica>on	
  supports.
Resource Qualifiers for Screen Size
        and Pixel Density
• Folder-name qualifiers
 ‣   Include	
  alterna>ve	
  resources	
  for	
  different	
  
     screen	
  sizes,	
  pixel	
  densi>es,	
  and	
  aspect	
  ra>os
 ‣   Screen	
  size	
  (small,	
  medium,	
  large),	
  Pixel	
  density	
  
     (ldpi,	
  mdpi,	
  hdpi,	
  nodpi),	
  Aspect	
  ra>o	
  (long,	
  
     notlong)

• Can be used independently, or in
  combination with each other
Manifest to Limit

• <supports-screens> manifest element to
  specify which screens your application can
  be run on
• A false value will force Android to use
  compatibility scaling to attempt to scale
  your application UI correctly
Best Practices for Resolution
          Independence


• Relative Layouts and Density-
  Independent Pixels
• Using Scalable Graphics Assets
• Provide Optimized Resources for
  Different Screens
• Testing, Testing and Testing
Android Menu System

• Android features a three-stage menu
  system optimized for small screens:
                               submenus
             expanded menu
icon menu
The Icon Menu

• It displays the icons and text for a
  limited number of Menu Items
  (typically six)
• If the menu contains more than the
  maximum number of visible Menu
  Items, a More Menu Item is displayed.
  When selected, it displays the
  expanded menu
The Expanded Menu

• The expanded menu is triggered when a
  user selects the More Menu Item from
  the icon menu
• It does not display icons. Pressing back
  from the expanded menu returns you to
  the icon menu
• You cannot force Android to display the
  expanded menu instead of the icon
  menu
Submenus

• Android does not support nested
  submenus, you can’t add a submenu to a
  submenu
• As with the extended menu, icons are not
  displayed in the submenu
Thank you :)

Más contenido relacionado

Destacado

HR Software | HRMS Software | Payroll Software | HRmangtaa
HR Software | HRMS Software | Payroll Software | HRmangtaaHR Software | HRMS Software | Payroll Software | HRmangtaa
HR Software | HRMS Software | Payroll Software | HRmangtaaXmx Solutions
 
ITIL® Foundation by AXELOS
ITIL® Foundation by AXELOSITIL® Foundation by AXELOS
ITIL® Foundation by AXELOSMarcio Amaral
 
Nbdxfigjrhb
NbdxfigjrhbNbdxfigjrhb
NbdxfigjrhbAbril649
 
Dlaczego opłaca się być innowacyjnym w mleczarstwie? Perspektywy rozwoju branży
Dlaczego opłaca się być innowacyjnym w mleczarstwie? Perspektywy rozwoju branżyDlaczego opłaca się być innowacyjnym w mleczarstwie? Perspektywy rozwoju branży
Dlaczego opłaca się być innowacyjnym w mleczarstwie? Perspektywy rozwoju branżyBetterSolutions
 
Cont10e u ch05_lecture
Cont10e u ch05_lectureCont10e u ch05_lecture
Cont10e u ch05_lectureDevin Bennett
 
The diplomatic and military
The diplomatic and militaryThe diplomatic and military
The diplomatic and militarykrich28
 
Manual de-usuario-prog.-esp
Manual de-usuario-prog.-espManual de-usuario-prog.-esp
Manual de-usuario-prog.-espFernando Aguilar
 
Tugas Akhir SMK N 2 Wonogiri "Rumah type carla 69" by Hesti Romadhoni
Tugas Akhir SMK N 2 Wonogiri "Rumah type carla 69" by Hesti RomadhoniTugas Akhir SMK N 2 Wonogiri "Rumah type carla 69" by Hesti Romadhoni
Tugas Akhir SMK N 2 Wonogiri "Rumah type carla 69" by Hesti RomadhoniHesti Romadhoni
 
Procesos de manufactura la rectificadora
Procesos de manufactura la rectificadoraProcesos de manufactura la rectificadora
Procesos de manufactura la rectificadoraJuan Tello El Potro
 
Rectificado superficies
Rectificado superficiesRectificado superficies
Rectificado superficiesComegui
 
Rectificado cilindrico
Rectificado cilindricoRectificado cilindrico
Rectificado cilindricoComegui
 
Ammanu pecha kucha 2016-01-22
Ammanu pecha kucha 2016-01-22 Ammanu pecha kucha 2016-01-22
Ammanu pecha kucha 2016-01-22 mvo-duurzaam
 
A Lei em livro da CPAD - Casa Publicadora das Assembléias de Deus.
A Lei em livro da CPAD - Casa Publicadora das Assembléias de Deus.A Lei em livro da CPAD - Casa Publicadora das Assembléias de Deus.
A Lei em livro da CPAD - Casa Publicadora das Assembléias de Deus.Bruno Glathardt
 
Open Partner Network _ Opportunités d'emploi, de travail et d'activités en ré...
Open Partner Network _ Opportunités d'emploi, de travail et d'activités en ré...Open Partner Network _ Opportunités d'emploi, de travail et d'activités en ré...
Open Partner Network _ Opportunités d'emploi, de travail et d'activités en ré...MGB Open Partner Network
 

Destacado (19)

HR Software | HRMS Software | Payroll Software | HRmangtaa
HR Software | HRMS Software | Payroll Software | HRmangtaaHR Software | HRMS Software | Payroll Software | HRmangtaa
HR Software | HRMS Software | Payroll Software | HRmangtaa
 
Stephan P Veilleux Resume
Stephan P Veilleux ResumeStephan P Veilleux Resume
Stephan P Veilleux Resume
 
My Resume - NEERAJ
My Resume - NEERAJMy Resume - NEERAJ
My Resume - NEERAJ
 
ITIL® Foundation by AXELOS
ITIL® Foundation by AXELOSITIL® Foundation by AXELOS
ITIL® Foundation by AXELOS
 
Nbdxfigjrhb
NbdxfigjrhbNbdxfigjrhb
Nbdxfigjrhb
 
Dlaczego opłaca się być innowacyjnym w mleczarstwie? Perspektywy rozwoju branży
Dlaczego opłaca się być innowacyjnym w mleczarstwie? Perspektywy rozwoju branżyDlaczego opłaca się być innowacyjnym w mleczarstwie? Perspektywy rozwoju branży
Dlaczego opłaca się być innowacyjnym w mleczarstwie? Perspektywy rozwoju branży
 
EDPyAE
EDPyAEEDPyAE
EDPyAE
 
Cont10e u ch05_lecture
Cont10e u ch05_lectureCont10e u ch05_lecture
Cont10e u ch05_lecture
 
The diplomatic and military
The diplomatic and militaryThe diplomatic and military
The diplomatic and military
 
Dibujo de ingenieria despiece
Dibujo de ingenieria despieceDibujo de ingenieria despiece
Dibujo de ingenieria despiece
 
Manual de-usuario-prog.-esp
Manual de-usuario-prog.-espManual de-usuario-prog.-esp
Manual de-usuario-prog.-esp
 
Tugas Akhir SMK N 2 Wonogiri "Rumah type carla 69" by Hesti Romadhoni
Tugas Akhir SMK N 2 Wonogiri "Rumah type carla 69" by Hesti RomadhoniTugas Akhir SMK N 2 Wonogiri "Rumah type carla 69" by Hesti Romadhoni
Tugas Akhir SMK N 2 Wonogiri "Rumah type carla 69" by Hesti Romadhoni
 
GLP-1 and Diabetes Mellitus
GLP-1 and Diabetes MellitusGLP-1 and Diabetes Mellitus
GLP-1 and Diabetes Mellitus
 
Procesos de manufactura la rectificadora
Procesos de manufactura la rectificadoraProcesos de manufactura la rectificadora
Procesos de manufactura la rectificadora
 
Rectificado superficies
Rectificado superficiesRectificado superficies
Rectificado superficies
 
Rectificado cilindrico
Rectificado cilindricoRectificado cilindrico
Rectificado cilindrico
 
Ammanu pecha kucha 2016-01-22
Ammanu pecha kucha 2016-01-22 Ammanu pecha kucha 2016-01-22
Ammanu pecha kucha 2016-01-22
 
A Lei em livro da CPAD - Casa Publicadora das Assembléias de Deus.
A Lei em livro da CPAD - Casa Publicadora das Assembléias de Deus.A Lei em livro da CPAD - Casa Publicadora das Assembléias de Deus.
A Lei em livro da CPAD - Casa Publicadora das Assembléias de Deus.
 
Open Partner Network _ Opportunités d'emploi, de travail et d'activités en ré...
Open Partner Network _ Opportunités d'emploi, de travail et d'activités en ré...Open Partner Network _ Opportunités d'emploi, de travail et d'activités en ré...
Open Partner Network _ Opportunités d'emploi, de travail et d'activités en ré...
 

Similar a Ch4 creating user interfaces

Workshop Android for Java Developers
Workshop Android for Java DevelopersWorkshop Android for Java Developers
Workshop Android for Java Developersmhant
 
Building Rich Dashboards with IBM Business Insight
Building Rich Dashboards with IBM Business InsightBuilding Rich Dashboards with IBM Business Insight
Building Rich Dashboards with IBM Business InsightDataClarity Corporation
 
Synapse india reviews on i phone and android os
Synapse india reviews on i phone and android osSynapse india reviews on i phone and android os
Synapse india reviews on i phone and android ossaritasingh19866
 
Android Custom Views
Android Custom ViewsAndroid Custom Views
Android Custom ViewsBabar Sanah
 
Session 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 applicationSession 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 applicationVu Tran Lam
 
Android and IOS UI Development (Android 5.0 and iOS 9.0)
Android and IOS UI Development (Android 5.0 and iOS 9.0)Android and IOS UI Development (Android 5.0 and iOS 9.0)
Android and IOS UI Development (Android 5.0 and iOS 9.0)Michael Shrove
 
Application Development - Overview on Android OS
Application Development - Overview on Android OSApplication Development - Overview on Android OS
Application Development - Overview on Android OSPankaj Maheshwari
 
User experience and interactions design
User experience and interactions design User experience and interactions design
User experience and interactions design Rakesh Jha
 
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptxMugiiiReee
 
Consistent UI Across Android Devices
Consistent UI Across Android DevicesConsistent UI Across Android Devices
Consistent UI Across Android DevicesIrene Duke
 
[PBO] Pertemuan 12 - Pemrograman Android
[PBO] Pertemuan 12 - Pemrograman Android[PBO] Pertemuan 12 - Pemrograman Android
[PBO] Pertemuan 12 - Pemrograman Androidrizki adam kurniawan
 

Similar a Ch4 creating user interfaces (20)

Workshop Android for Java Developers
Workshop Android for Java DevelopersWorkshop Android for Java Developers
Workshop Android for Java Developers
 
Building Rich Dashboards with IBM Business Insight
Building Rich Dashboards with IBM Business InsightBuilding Rich Dashboards with IBM Business Insight
Building Rich Dashboards with IBM Business Insight
 
Android dev tips
Android dev tipsAndroid dev tips
Android dev tips
 
Ui 5
Ui   5Ui   5
Ui 5
 
Androidify workshop
Androidify workshopAndroidify workshop
Androidify workshop
 
Synapse india reviews on i phone and android os
Synapse india reviews on i phone and android osSynapse india reviews on i phone and android os
Synapse india reviews on i phone and android os
 
Android Custom Views
Android Custom ViewsAndroid Custom Views
Android Custom Views
 
Session 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 applicationSession 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 application
 
Android and IOS UI Development (Android 5.0 and iOS 9.0)
Android and IOS UI Development (Android 5.0 and iOS 9.0)Android and IOS UI Development (Android 5.0 and iOS 9.0)
Android and IOS UI Development (Android 5.0 and iOS 9.0)
 
Authoring metaphors
Authoring metaphorsAuthoring metaphors
Authoring metaphors
 
Synapse india mobile apps update
Synapse india mobile apps updateSynapse india mobile apps update
Synapse india mobile apps update
 
Application Development - Overview on Android OS
Application Development - Overview on Android OSApplication Development - Overview on Android OS
Application Development - Overview on Android OS
 
User experience and interactions design
User experience and interactions design User experience and interactions design
User experience and interactions design
 
Android bootcamp-day1
Android bootcamp-day1Android bootcamp-day1
Android bootcamp-day1
 
Introduction of Xcode
Introduction of XcodeIntroduction of Xcode
Introduction of Xcode
 
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
 
Consistent UI Across Android Devices
Consistent UI Across Android DevicesConsistent UI Across Android Devices
Consistent UI Across Android Devices
 
Android - Activity, Services
Android - Activity, ServicesAndroid - Activity, Services
Android - Activity, Services
 
[PBO] Pertemuan 12 - Pemrograman Android
[PBO] Pertemuan 12 - Pemrograman Android[PBO] Pertemuan 12 - Pemrograman Android
[PBO] Pertemuan 12 - Pemrograman Android
 
Visual basic
Visual basicVisual basic
Visual basic
 

Más de Shih-Hsiang Lin

Introduction to Apache Ant
Introduction to Apache AntIntroduction to Apache Ant
Introduction to Apache AntShih-Hsiang Lin
 
Introduction to GNU Make Programming Language
Introduction to GNU Make Programming LanguageIntroduction to GNU Make Programming Language
Introduction to GNU Make Programming LanguageShih-Hsiang Lin
 
Ch6 file, saving states, and preferences
Ch6 file, saving states, and preferencesCh6 file, saving states, and preferences
Ch6 file, saving states, and preferencesShih-Hsiang Lin
 
[C++ gui programming with qt4] chap9
[C++ gui programming with qt4] chap9[C++ gui programming with qt4] chap9
[C++ gui programming with qt4] chap9Shih-Hsiang Lin
 
Ch5 intent broadcast receivers adapters and internet
Ch5 intent broadcast receivers adapters and internetCh5 intent broadcast receivers adapters and internet
Ch5 intent broadcast receivers adapters and internetShih-Hsiang Lin
 
Ch3 creating application and activities
Ch3 creating application and activitiesCh3 creating application and activities
Ch3 creating application and activitiesShih-Hsiang Lin
 
[C++ GUI Programming with Qt4] chap7
[C++ GUI Programming with Qt4] chap7[C++ GUI Programming with Qt4] chap7
[C++ GUI Programming with Qt4] chap7Shih-Hsiang Lin
 
[C++ GUI Programming with Qt4] chap4
[C++ GUI Programming with Qt4] chap4[C++ GUI Programming with Qt4] chap4
[C++ GUI Programming with Qt4] chap4Shih-Hsiang Lin
 
Introduction to homography
Introduction to homographyIntroduction to homography
Introduction to homographyShih-Hsiang Lin
 
Project Hosting by Google
Project Hosting by GoogleProject Hosting by Google
Project Hosting by GoogleShih-Hsiang Lin
 
An Introduction to Hidden Markov Model
An Introduction to Hidden Markov ModelAn Introduction to Hidden Markov Model
An Introduction to Hidden Markov ModelShih-Hsiang Lin
 

Más de Shih-Hsiang Lin (13)

Introduction to Apache Ant
Introduction to Apache AntIntroduction to Apache Ant
Introduction to Apache Ant
 
Introduction to GNU Make Programming Language
Introduction to GNU Make Programming LanguageIntroduction to GNU Make Programming Language
Introduction to GNU Make Programming Language
 
Ch6 file, saving states, and preferences
Ch6 file, saving states, and preferencesCh6 file, saving states, and preferences
Ch6 file, saving states, and preferences
 
[C++ gui programming with qt4] chap9
[C++ gui programming with qt4] chap9[C++ gui programming with qt4] chap9
[C++ gui programming with qt4] chap9
 
Ch5 intent broadcast receivers adapters and internet
Ch5 intent broadcast receivers adapters and internetCh5 intent broadcast receivers adapters and internet
Ch5 intent broadcast receivers adapters and internet
 
Ch3 creating application and activities
Ch3 creating application and activitiesCh3 creating application and activities
Ch3 creating application and activities
 
[C++ GUI Programming with Qt4] chap7
[C++ GUI Programming with Qt4] chap7[C++ GUI Programming with Qt4] chap7
[C++ GUI Programming with Qt4] chap7
 
[C++ GUI Programming with Qt4] chap4
[C++ GUI Programming with Qt4] chap4[C++ GUI Programming with Qt4] chap4
[C++ GUI Programming with Qt4] chap4
 
Function pointer
Function pointerFunction pointer
Function pointer
 
Introduction to homography
Introduction to homographyIntroduction to homography
Introduction to homography
 
Git basic
Git basicGit basic
Git basic
 
Project Hosting by Google
Project Hosting by GoogleProject Hosting by Google
Project Hosting by Google
 
An Introduction to Hidden Markov Model
An Introduction to Hidden Markov ModelAn Introduction to Hidden Markov Model
An Introduction to Hidden Markov Model
 

Último

Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptxMusic 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptxleah joy valeriano
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 

Último (20)

Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptxMusic 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 

Ch4 creating user interfaces

  • 1. Ch4. Creating User Interface Browny 10, May, 2011
  • 2. Outline • Introducing Views • Introducing Layouts • Creating New Views • Drawable Resources • Creating and Using Menus
  • 3. Terminology • View ‣ ,    UI  controls    layout  classes    View   ,    control    widget  (not  home  screen  or  App   Widgets) • View Groups ‣ View    extension,    child  Views • Activities ‣  user  interface,    View  assign     Ac>vity
  • 4. Creating Activity with Views(1/2) • Activity user interface ‣ Call  setContentView,  passing  in  the  View   instance    layout  resources  (layout  resource  ID) ‣ Almost  always  use  in  onCreate  handler • Get references to the Views used within a layout with the findViewById method
  • 5. Creating Activity with Views(2/2) Inflating an Activity layout Creating a UI layout in code
  • 6. The Android Widget Toolbox • Android supplies a toolbox of standard Views to help you create simple interfaces • TextView, EditText, ListView, Spinner, Button, CheckBox, RadioButton, ViewFlipper, QuickContactBadge http://developer.android.com/guide/tutorials/views/index.html
  • 7. Layouts • Layout managers (layouts) are extensions of the ViewGroup class used to position child controls for your UI • The Android SDK includes some simple layouts to help you construct your UI http://developer.android.com/guide/topics/ui/
  • 8. Using Layouts • Preferred way ‣ Implement  layouts  by  using  XML  as  external   resources • A simple layout that places a TextView above an EditText control using a vertical LinearLayout
  • 11. Optimizing Layouts(1/2) • Inflating layouts into your Activities is an expensive process • Good practice ‣ Keep  your  layouts  as  simple  as  possible ‣ Avoid  to  inflate  an  en>rely  new  layout  for  small   changes  to  an  exis>ng  one
  • 12. Optimizing Layouts(2/2) • Avoid unnecessary nesting (Don’t put one layout within another unless it is necessary) • Avoid using too many Views • Avoid deep nesting (It’s good practice to restrict nesting to fewer than 10 levels) • Android SDK includes the layoutopt command line tool
  • 13. Creating New Views • Modify or Extend (appearance and/or behavior) an existing control • Combine Views to create atomic, reusable controls (leverage the functionality of several interconnected Views) • Create an entirely new control
  • 14. Modifying Existing Views • Create a new class that extends an existing control • To override the appearance (onDraw) • To override behavior (onKeyDown)
  • 15.
  • 16. Creating Compound Controls • Create compound controls by extending a ViewGroup (usually a layout) • Choose the layout class that’s most suitable for positioning the child controls, and extend it
  • 17. Compound View: Using an External Resource(1/3)
  • 18. Compound View: Using an External Resource(2/3) • To use this layout for your new View, override the View’s constructor to inflate the layout resource using the inflate method from the LayoutInflate system service
  • 19. Compound View: Using an External Resource(3/3)
  • 21. Hook up the event handlers for each child control
  • 22. Creating Custom Views • Extend either the View (lightweight solution) or SurfaceView classes (supports drawing from a background thread and using openGL for 3D graphics) • The View class provides a Canvas object with a series of draw methods and Paint classes. Use them to create a visual interface with bitmaps and raster graphics
  • 23. Creating a New Visual Interface(1/2) • The base View class presents a distinctly empty 100-pixel-by-100- pixel square • You need to override the onMeasure and onDraw methods to change it
  • 24. Creating a New Visual Interface(2/2)
  • 25. Drawing Your Control(1/3) • Android provides a variety of tools to help draw your design on the Canvas using various Paint objects • The Canvas class includes helper methods for drawing primitive 2D objects including circles, lines, etc. • Also supports transformations that let you rotate, translate (move), and scale (resize) the Canvas while you draw on it
  • 26. Drawing Your Control(2/3) • Any object created in your onDraw method will be created and destroyed every time the screen refreshes ( ) • Improve efficiency by making as many of these objects (particularly instances of Paint and Drawable) class-scoped and by moving their creation into the constructor
  • 28. Sizing Your Control(1/3) • The onMeasure method is called when the control’s parent is laying out its child controls ‣ It  asks  the  ques>on  ‘‘How  much  space  will  you   use?’’  and  passes  in  two  parameters:   widthMeasureSpec  and  heightMeasureSpec • Rather than return a result, you pass the View’s height and width into the setMeasuredDimension method
  • 29.
  • 30. Sizing Your Control (3/3) • Before widthMeasureSpec and heightMeasureSpec can be used, they first need to be decoded using the static getMode and getSize methods from the MeasureSpec class • Depending on the mode value, the size represents either the maximum space available for the control (AT_MOST), or the exact size that your control will occupy (EXACTLY)
  • 31. Handling User Interaction Events (1/2) • Android exposes several virtual event handlers that let you react to user input ‣ onKeyDown  (D-­‐pad,  keyboard,  hang-­‐up,  call,   back,  and  camera  buPons) ‣ onKeyUp ‣ onTrackballEvent ‣ onTouchEvent
  • 33. Using Custom Controls In Code In XML
  • 34. Drawable Resources • Introduce several new types of Drawables resources • Show how to use these resources to create user interfaces that are independent of screen size and resolution
  • 35. Shapes, Colors, and Gradients • Android includes a number of simple Drawable resource types that can be defined entirely in XML ‣ ColorDrawable,  ShapeDrawable,  and  GradientDrawable   classes ‣ Composite  Drawables  (Transforma>ve  Drawables,  Layer   Drawable,  State  List  Drawables,  Level  List  Drawables) ‣ NinePatch  Drawable • These resources are stored in the res/drawable folder and can then be identified in code by their lowercase XML filenames
  • 36. Resolution and Density Independence • The resource directory qualifiers ‣ Store  alterna>ve  assets  and  layouts  for  different   screen  configura>ons   • The manifest elements ‣ Limit  the  screen  sizes  your  applica>on  supports.
  • 37. Resource Qualifiers for Screen Size and Pixel Density • Folder-name qualifiers ‣ Include  alterna>ve  resources  for  different   screen  sizes,  pixel  densi>es,  and  aspect  ra>os ‣ Screen  size  (small,  medium,  large),  Pixel  density   (ldpi,  mdpi,  hdpi,  nodpi),  Aspect  ra>o  (long,   notlong) • Can be used independently, or in combination with each other
  • 38. Manifest to Limit • <supports-screens> manifest element to specify which screens your application can be run on • A false value will force Android to use compatibility scaling to attempt to scale your application UI correctly
  • 39. Best Practices for Resolution Independence • Relative Layouts and Density- Independent Pixels • Using Scalable Graphics Assets • Provide Optimized Resources for Different Screens • Testing, Testing and Testing
  • 40. Android Menu System • Android features a three-stage menu system optimized for small screens: submenus expanded menu icon menu
  • 41. The Icon Menu • It displays the icons and text for a limited number of Menu Items (typically six) • If the menu contains more than the maximum number of visible Menu Items, a More Menu Item is displayed. When selected, it displays the expanded menu
  • 42. The Expanded Menu • The expanded menu is triggered when a user selects the More Menu Item from the icon menu • It does not display icons. Pressing back from the expanded menu returns you to the icon menu • You cannot force Android to display the expanded menu instead of the icon menu
  • 43. Submenus • Android does not support nested submenus, you can’t add a submenu to a submenu • As with the extended menu, icons are not displayed in the submenu