SlideShare a Scribd company logo
Busy Android Developer's Guide to UI Ted Neward Neward & Associates http://www.tedneward.com | ted@tedneward.com
Credentials Who is this guy? Architectural Consultant, Neudesic Software Principal, Architect, Consultant and Mentor ask me how I can help your project or your team Microsoft MVP (F#, C#, Architect) JSR 175, 277 Expert Group Member Author Professional F# 2.0 (w/Erickson, et al; Wrox, 2010) Effective Enterprise Java (Addison-Wesley, 2004) C# In a Nutshell (w/Drayton, et all; OReilly, 2003) SSCLI Essentials (w/Stutz, et al; OReilly, 2003) Server-Based Java Programming (Manning, 2000) Blog: http://blogs.tedneward.com Papers: http://www.tedneward.com/writings Twitter: @tedneward
Objectives Our goal here today is... ... to get familiar with the various Android UI elements ... to come to understand XML layouts ... to learn how to handle events within Android UIs
Activities and Tasks Activity somewhat akin to a web page or screen public class that extends android.app.Activity activities have event methods for override onCreate: activity "constructor" onDestroy: activity "finalizer" onStart/onResume/onPause/onStop/onRestart flow remember to always call up the inheritance chain
Activities and Tasks Tasks Tasks are the logical thread of use through Activities usually starting from the Home screen Tasks form a "back stack" of Activity instances "back" button removes the top card, destroys that activity Tasks are distinct from one another a new task creates a new stack of cards this means more than one Activity instance of the same type is possible Tasks cross applications and processes in this respect, Activities are like web pages
Viewables View and ViewGroups View is the base class for "widgets" ViewGroup is the base for Composite-patterned containers of other View objects (including other ViewGroup instances) Each Activity can hold one content View most often, this is a ViewGroup, forming a hierarchy Custom Views and ViewGroups you can do them, but it's pretty rare
Viewables Widgets (android.widget) "Push Me": Button, CompoundButton, CheckBox, ImageButton, RadioButton Text: EditText, TextView, NumberPicker, TextSwitcher Graphics: Gallery, ImageSwitcher, ImageView Selectors: RatingBar, SeekBar, Spinner, Switch Time: AnalogClock, DigitalClock, Chronometer, CalendarView, DatePicker, TimePicker Composite: ListView, SlidingDrawer, TabHost Media: MediaController Space (literally, just that--empty space!) ... and a few more
Viewables Layouts (android.widget) LinearLayout RelativeLayout TableLayout GridLayout AbsoluteLayout (bad!) FrameLayout (mostly useless!)
Viewables Dialogs (android.app) are a special case of Activity AlertDialog (OK/Cancel/Help, etc) ProgressDialog (56 of 100...) DatePickerDialog TimePickerDialog But Dialogs are not Activities Dialogs are always created and displayed as part of (and are "owned" by) an Activity; as such, they are intimately wrapped up in their host Activity's code AlertDialog is the workhorse here
Creation Two ways of creating UIs in Android either create UI "by hand" in Java or using XML-based layout (resource) file layout resources are not tied to an Activity; they are just a group of Views laid out in an XML file layout resources can be "inflated" from XML into UI objects (via a system service) Activity.setContentView() is a shortcut way to do this
Layout Resources Layout resources are in res/layout directory XML file name corresponds to R.layout.{filename} Root element is (usually) a ViewGroup (Layout class) android: namespace is mandatory element attributes describe "setter" values android:id is critical for manipulation "@+{prefix}/{name}" defines new R.{prefix}.{name} id {prefix} is most often "id" but isn't required IDs don't have to be unique across the entire tree (but usually are)
Layout Resources <LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; android:orientation=&quot;vertical&quot; android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;fill_parent&quot;> <ListView android:id=&quot;@+my_team_ids/lstInvitees&quot; android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;wrap_content&quot; android:padding=&quot;6dip&quot; /> <LinearLayout  android:orientation=&quot;horizontal&quot; android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;fill_parent&quot; android:gravity=&quot;bottom&quot;> <TextView android:text=&quot;Add:&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot; /> <EditText android:id=&quot;@+my_team_ids/txtNewTeamMember&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot; android:hint=&quot;(Email address)&quot; android:maxLines=&quot;1&quot; /> <ImageButton android:id=&quot;@+my_team_ids/btnInvite&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot; android:src=&quot;@android:drawable/sym_action_chat&quot; /> </LinearLayout> </LinearLayout>
Layout Resources Layout resources can be &quot;tuned&quot; like all resources, layouts can be spceialized to particular scenarios screen size: &quot;small&quot;, &quot;normal&quot;, &quot;large&quot;, &quot;xlarge&quot; orientation: &quot;port&quot;, &quot;land&quot; pixel density: &quot;ldpi&quot;, &quot;mdpi&quot;, &quot;hdpi&quot;, &quot;xhdpi&quot;, &quot;nodpi&quot;, &quot;tvdpi&quot; platform version: &quot;v3&quot;, &quot;v4&quot;, &quot;v7&quot;, ... this is one way to customize UI to different device profiles the above qualifiers MUST be in that order see ${SDK}/docs/guide/topics/resources/providing-resources.html
Menus Menus Activities can also have menubar items associated with them best used for actions that aren't common or frequent Menus are often defined in layout (res/menu) menu: define a menu, a container for menu items item: define a menuitem, with id, icon and title (text) group: convenience grouping of item elements (invisible)
Menus <menu xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;> <item android:id=&quot;@+id/new_game&quot; android:icon=&quot;@drawable/ic_new_game&quot; android:title=&quot;@string/new_game&quot; /> <item android:id=&quot;@+id/help&quot; android:icon=&quot;@drawable/ic_help&quot; android:title=&quot;@string/help&quot; /> </menu>
Menus ActionBar (3.0+) A set of menus/menuitems appearing at the top generally only useful for tablets
Event-handling Most Views/ViewGroups offer events for code to subscribe to These are called &quot;InputEvents&quot; Most of the time, this is the classic &quot;Listener&quot; idiom View.OnClickListeners can be wired up in the XML layout Most of the time, these are wired up in onCreate()
Intents Moving from one Activity to another requires an Intent Intent = Action (verb) + Context (target) easiest Intent is the &quot;launch the Activity&quot; Intent Intent next = new Intent(this, NextActivity.class); startActivity(next);
Threading Good Thread hygiene is critical here This is a phone--you don't own the machine! Android isn't quite like Java, and has a slightly different &quot;take&quot; on the threads-and-UI position no blocking behaviors (in general) NO UI modifications from non-UI thread If the UI thread is inactive for more than 5 seconds, bye! Android provides Handlers, which can be sent Messages that will then be processed on the Activity's UI thread Java5 provides a few other constructs as well
Wrapping up &quot;What do you know?&quot;
Summary Android is a Java-based mobile device framework ... but it's not Java ... and it's not a web app technology ... and it's definitely not Swing or SWT
Resources Busy Coder’s Guide to Android Mark Murphy, http://www.commonsware.com Android website http://developer.android.com Presentations by this guy Busy Android Dev's Guide to Persistence Busy Android Dev's Guide to Communication ... and more
Ad

Recommended

Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
JAX London
 
When Sightly Meets Slice by Tomasz Niedźwiedź
When Sightly Meets Slice by Tomasz Niedźwiedź
AEM HUB
 
Ant User Guide
Ant User Guide
Muthuselvam RS
 
slingmodels
slingmodels
Ankur Chauhan
 
SharePoint Saturday St. Louis - SharePoint & jQuery
SharePoint Saturday St. Louis - SharePoint & jQuery
Mark Rackley
 
Introduction to Sightly and Sling Models
Introduction to Sightly and Sling Models
Stefano Celentano
 
Ant - Another Neat Tool
Ant - Another Neat Tool
Kanika2885
 
Html 5 in a big nutshell
Html 5 in a big nutshell
Lennart Schoors
 
API Technical Writing
API Technical Writing
Sarah Maddox
 
Sightly - AEM6 UI Development using JS and JAVA
Sightly - AEM6 UI Development using JS and JAVA
Yash Mody
 
#SPSEMEA SharePoint & jQuery - What I wish I would have known a year ago..
#SPSEMEA SharePoint & jQuery - What I wish I would have known a year ago..
Mark Rackley
 
Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3
Fabien Potencier
 
Building search app with ElasticSearch
Building search app with ElasticSearch
Lukas Vlcek
 
WordPress and Ajax
WordPress and Ajax
Ronald Huereca
 
AngularJs presentation
AngularJs presentation
Phan Tuan
 
MVC Frameworks for building PHP Web Applications
MVC Frameworks for building PHP Web Applications
Vforce Infotech
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
ipolevoy
 
ActiveJDBC - ActiveRecord implementation in Java
ActiveJDBC - ActiveRecord implementation in Java
ipolevoy
 
[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JS
Ivano Malavolta
 
Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!
Doris Chen
 
React native
React native
Mohammed El Rafie Tarabay
 
Javascript Best Practices
Javascript Best Practices
Christian Heilmann
 
Mobile HTML, CSS, and JavaScript
Mobile HTML, CSS, and JavaScript
franksvalli
 
Aem best practices
Aem best practices
Jitendra Tomar
 
Intro to html5 Boilerplate
Intro to html5 Boilerplate
Michael Enslow
 
[2015/2016] JavaScript
[2015/2016] JavaScript
Ivano Malavolta
 
Looking into HTML5
Looking into HTML5
Christopher Schmitt
 
JavaScript Library Overview
JavaScript Library Overview
jeresig
 
Java EE | Modular EJBs for Enterprise OSGi | Tim Ward
Java EE | Modular EJBs for Enterprise OSGi | Tim Ward
JAX London
 
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
JAX London
 

More Related Content

What's hot (20)

API Technical Writing
API Technical Writing
Sarah Maddox
 
Sightly - AEM6 UI Development using JS and JAVA
Sightly - AEM6 UI Development using JS and JAVA
Yash Mody
 
#SPSEMEA SharePoint & jQuery - What I wish I would have known a year ago..
#SPSEMEA SharePoint & jQuery - What I wish I would have known a year ago..
Mark Rackley
 
Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3
Fabien Potencier
 
Building search app with ElasticSearch
Building search app with ElasticSearch
Lukas Vlcek
 
WordPress and Ajax
WordPress and Ajax
Ronald Huereca
 
AngularJs presentation
AngularJs presentation
Phan Tuan
 
MVC Frameworks for building PHP Web Applications
MVC Frameworks for building PHP Web Applications
Vforce Infotech
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
ipolevoy
 
ActiveJDBC - ActiveRecord implementation in Java
ActiveJDBC - ActiveRecord implementation in Java
ipolevoy
 
[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JS
Ivano Malavolta
 
Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!
Doris Chen
 
React native
React native
Mohammed El Rafie Tarabay
 
Javascript Best Practices
Javascript Best Practices
Christian Heilmann
 
Mobile HTML, CSS, and JavaScript
Mobile HTML, CSS, and JavaScript
franksvalli
 
Aem best practices
Aem best practices
Jitendra Tomar
 
Intro to html5 Boilerplate
Intro to html5 Boilerplate
Michael Enslow
 
[2015/2016] JavaScript
[2015/2016] JavaScript
Ivano Malavolta
 
Looking into HTML5
Looking into HTML5
Christopher Schmitt
 
JavaScript Library Overview
JavaScript Library Overview
jeresig
 
API Technical Writing
API Technical Writing
Sarah Maddox
 
Sightly - AEM6 UI Development using JS and JAVA
Sightly - AEM6 UI Development using JS and JAVA
Yash Mody
 
#SPSEMEA SharePoint & jQuery - What I wish I would have known a year ago..
#SPSEMEA SharePoint & jQuery - What I wish I would have known a year ago..
Mark Rackley
 
Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3
Fabien Potencier
 
Building search app with ElasticSearch
Building search app with ElasticSearch
Lukas Vlcek
 
AngularJs presentation
AngularJs presentation
Phan Tuan
 
MVC Frameworks for building PHP Web Applications
MVC Frameworks for building PHP Web Applications
Vforce Infotech
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
ipolevoy
 
ActiveJDBC - ActiveRecord implementation in Java
ActiveJDBC - ActiveRecord implementation in Java
ipolevoy
 
[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JS
Ivano Malavolta
 
Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!
Doris Chen
 
Mobile HTML, CSS, and JavaScript
Mobile HTML, CSS, and JavaScript
franksvalli
 
Intro to html5 Boilerplate
Intro to html5 Boilerplate
Michael Enslow
 
JavaScript Library Overview
JavaScript Library Overview
jeresig
 

Viewers also liked (20)

Java EE | Modular EJBs for Enterprise OSGi | Tim Ward
Java EE | Modular EJBs for Enterprise OSGi | Tim Ward
JAX London
 
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
JAX London
 
Java Tech & Tools | Continuous Delivery - the Writing is on the Wall | John S...
Java Tech & Tools | Continuous Delivery - the Writing is on the Wall | John S...
JAX London
 
Java Tech & Tools | Mapping, GIS and Geolocating Data in Java | Joachim Van d...
Java Tech & Tools | Mapping, GIS and Geolocating Data in Java | Joachim Van d...
JAX London
 
Modules all the way down: OSGi and the Java Platform Module System
Modules all the way down: OSGi and the Java Platform Module System
Tim Ellison
 
Pitfalls of migrating projects to JDK 9
Pitfalls of migrating projects to JDK 9
Pavel Bucek
 
Java modularity: life after Java 9
Java modularity: life after Java 9
Sander Mak (@Sander_Mak)
 
Alberti Center Colloquium Series - Dr. Jamie Ostrov
Alberti Center Colloquium Series - Dr. Jamie Ostrov
UB Alberti Center for Bullying Abuse Prevention
 
2008 Winter Newsletter
2008 Winter Newsletter
Direct Relief
 
StarWest 2013 Performance is not an afterthought – make it a part of your Agi...
StarWest 2013 Performance is not an afterthought – make it a part of your Agi...
Andreas Grabner
 
Lengua anuncio
Lengua anuncio
franky226
 
Indonesian internationaltrade
Indonesian internationaltrade
Rohit Jadhav
 
Stenden master l&i 8 maart 2013
Stenden master l&i 8 maart 2013
Augustus consultancy
 
2008 Spring Newsletter
2008 Spring Newsletter
Direct Relief
 
9th Annual Safe Schools Initiative Seminar
9th Annual Safe Schools Initiative Seminar
UB Alberti Center for Bullying Abuse Prevention
 
DevOps and Performance - Why, How and Best Practices - DevOps Meetup Sydney
DevOps and Performance - Why, How and Best Practices - DevOps Meetup Sydney
Andreas Grabner
 
Pencemaran air
Pencemaran air
bungachinta
 
Dutch Data Vault Masters: Same-As Struggles
Dutch Data Vault Masters: Same-As Struggles
Sander Robijns
 
Hum2310 sm2015 syllabus
Hum2310 sm2015 syllabus
ProfWillAdams
 
Java EE | Modular EJBs for Enterprise OSGi | Tim Ward
Java EE | Modular EJBs for Enterprise OSGi | Tim Ward
JAX London
 
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
JAX London
 
Java Tech & Tools | Continuous Delivery - the Writing is on the Wall | John S...
Java Tech & Tools | Continuous Delivery - the Writing is on the Wall | John S...
JAX London
 
Java Tech & Tools | Mapping, GIS and Geolocating Data in Java | Joachim Van d...
Java Tech & Tools | Mapping, GIS and Geolocating Data in Java | Joachim Van d...
JAX London
 
Modules all the way down: OSGi and the Java Platform Module System
Modules all the way down: OSGi and the Java Platform Module System
Tim Ellison
 
Pitfalls of migrating projects to JDK 9
Pitfalls of migrating projects to JDK 9
Pavel Bucek
 
2008 Winter Newsletter
2008 Winter Newsletter
Direct Relief
 
StarWest 2013 Performance is not an afterthought – make it a part of your Agi...
StarWest 2013 Performance is not an afterthought – make it a part of your Agi...
Andreas Grabner
 
Lengua anuncio
Lengua anuncio
franky226
 
Indonesian internationaltrade
Indonesian internationaltrade
Rohit Jadhav
 
2008 Spring Newsletter
2008 Spring Newsletter
Direct Relief
 
DevOps and Performance - Why, How and Best Practices - DevOps Meetup Sydney
DevOps and Performance - Why, How and Best Practices - DevOps Meetup Sydney
Andreas Grabner
 
Dutch Data Vault Masters: Same-As Struggles
Dutch Data Vault Masters: Same-As Struggles
Sander Robijns
 
Hum2310 sm2015 syllabus
Hum2310 sm2015 syllabus
ProfWillAdams
 
Ad

Similar to Android | Busy Java Developers Guide to Android: UI | Ted Neward (20)

Geekcamp Android
Geekcamp Android
Hean Hong Leong
 
Android Tutorial
Android Tutorial
Fun2Do Labs
 
Android L01 - Warm Up
Android L01 - Warm Up
Mohammad Shaker
 
Android ui layout
Android ui layout
Krazy Koder
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recievers
Utkarsh Mankad
 
Spsemea j query
Spsemea j query
Mark Rackley
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
Chiew Carol
 
Introduction to Android Programming
Introduction to Android Programming
Raveendra R
 
How to create ui using droid draw
How to create ui using droid draw
info_zybotech
 
Marakana Android User Interface
Marakana Android User Interface
Marko Gargenta
 
A Complete Tour of JSF 2
A Complete Tour of JSF 2
Jim Driscoll
 
Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)
Fafadia Tech
 
Lec005 android start_program
Lec005 android start_program
Eyad Almasri
 
01 09 - graphical user interface - basic widgets
01 09 - graphical user interface - basic widgets
Siva Kumar reddy Vasipally
 
SharePoint Saturday NYC - SharePoint and jQuery, what I wish I would have kno...
SharePoint Saturday NYC - SharePoint and jQuery, what I wish I would have kno...
Mark Rackley
 
Android apps development
Android apps development
Monir Zzaman
 
Introduction to Andriod Studio Lecture note: Android Development Lecture 1.pdf
Introduction to Andriod Studio Lecture note: Android Development Lecture 1.pdf
AliyuIshaq2
 
android layouts
android layouts
Deepa Rani
 
21 android2 updated
21 android2 updated
GhanaGTUG
 
Intro to Android Programming
Intro to Android Programming
Peter van der Linden
 
Android Tutorial
Android Tutorial
Fun2Do Labs
 
Android ui layout
Android ui layout
Krazy Koder
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recievers
Utkarsh Mankad
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
Chiew Carol
 
Introduction to Android Programming
Introduction to Android Programming
Raveendra R
 
How to create ui using droid draw
How to create ui using droid draw
info_zybotech
 
Marakana Android User Interface
Marakana Android User Interface
Marko Gargenta
 
A Complete Tour of JSF 2
A Complete Tour of JSF 2
Jim Driscoll
 
Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)
Fafadia Tech
 
Lec005 android start_program
Lec005 android start_program
Eyad Almasri
 
01 09 - graphical user interface - basic widgets
01 09 - graphical user interface - basic widgets
Siva Kumar reddy Vasipally
 
SharePoint Saturday NYC - SharePoint and jQuery, what I wish I would have kno...
SharePoint Saturday NYC - SharePoint and jQuery, what I wish I would have kno...
Mark Rackley
 
Android apps development
Android apps development
Monir Zzaman
 
Introduction to Andriod Studio Lecture note: Android Development Lecture 1.pdf
Introduction to Andriod Studio Lecture note: Android Development Lecture 1.pdf
AliyuIshaq2
 
android layouts
android layouts
Deepa Rani
 
21 android2 updated
21 android2 updated
GhanaGTUG
 
Ad

More from JAX London (20)

Keynote | Middleware Everywhere - Ready for Mobile and Cloud | Dr. Mark Little
Keynote | Middleware Everywhere - Ready for Mobile and Cloud | Dr. Mark Little
JAX London
 
Spring Day | WaveMaker - Spring Roo - SpringSource Tool Suite: Choosing the R...
Spring Day | WaveMaker - Spring Roo - SpringSource Tool Suite: Choosing the R...
JAX London
 
Spring Day | Behind the Scenes at Spring Batch | Dave Syer
Spring Day | Behind the Scenes at Spring Batch | Dave Syer
JAX London
 
Spring Day | Spring 3.1 in a Nutshell | Sam Brannen
Spring Day | Spring 3.1 in a Nutshell | Sam Brannen
JAX London
 
Spring Day | Identity Management with Spring Security | Dave Syer
Spring Day | Identity Management with Spring Security | Dave Syer
JAX London
 
Spring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard Wolff
JAX London
 
Spring Day | Data Access 2.0? Please Welcome Spring Data! | Oliver Gierke
Spring Day | Data Access 2.0? Please Welcome Spring Data! | Oliver Gierke
JAX London
 
Keynote | The Rise and Fall and Rise of Java | James Governor
Keynote | The Rise and Fall and Rise of Java | James Governor
JAX London
 
Java Tech & Tools | OSGi Best Practices | Emily Jiang
Java Tech & Tools | OSGi Best Practices | Emily Jiang
JAX London
 
Java Tech & Tools | Beyond the Data Grid: Coherence, Normalisation, Joins and...
Java Tech & Tools | Beyond the Data Grid: Coherence, Normalisation, Joins and...
JAX London
 
Java Tech & Tools | Big Blobs: Moving Big Data In and Out of the Cloud | Adri...
Java Tech & Tools | Big Blobs: Moving Big Data In and Out of the Cloud | Adri...
JAX London
 
Java Tech & Tools | Social Media in Programming in Java | Khanderao Kand
Java Tech & Tools | Social Media in Programming in Java | Khanderao Kand
JAX London
 
Java Tech & Tools | Just Keep Passing the Message | Russel Winder
Java Tech & Tools | Just Keep Passing the Message | Russel Winder
JAX London
 
Java Tech & Tools | Grails in the Java Enterprise | Peter Ledbrook
Java Tech & Tools | Grails in the Java Enterprise | Peter Ledbrook
JAX London
 
Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sande...
Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sande...
JAX London
 
Java EE | Apache TomEE - Java EE Web Profile on Tomcat | Jonathan Gallimore
Java EE | Apache TomEE - Java EE Web Profile on Tomcat | Jonathan Gallimore
JAX London
 
Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...
Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...
JAX London
 
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
JAX London
 
Java Core | Modern Java Concurrency | Martijn Verburg & Ben Evans
Java Core | Modern Java Concurrency | Martijn Verburg & Ben Evans
JAX London
 
Java Core | Concurrency in the Java Language and Platform | Fredrik Ohrstrom
Java Core | Concurrency in the Java Language and Platform | Fredrik Ohrstrom
JAX London
 
Keynote | Middleware Everywhere - Ready for Mobile and Cloud | Dr. Mark Little
Keynote | Middleware Everywhere - Ready for Mobile and Cloud | Dr. Mark Little
JAX London
 
Spring Day | WaveMaker - Spring Roo - SpringSource Tool Suite: Choosing the R...
Spring Day | WaveMaker - Spring Roo - SpringSource Tool Suite: Choosing the R...
JAX London
 
Spring Day | Behind the Scenes at Spring Batch | Dave Syer
Spring Day | Behind the Scenes at Spring Batch | Dave Syer
JAX London
 
Spring Day | Spring 3.1 in a Nutshell | Sam Brannen
Spring Day | Spring 3.1 in a Nutshell | Sam Brannen
JAX London
 
Spring Day | Identity Management with Spring Security | Dave Syer
Spring Day | Identity Management with Spring Security | Dave Syer
JAX London
 
Spring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard Wolff
JAX London
 
Spring Day | Data Access 2.0? Please Welcome Spring Data! | Oliver Gierke
Spring Day | Data Access 2.0? Please Welcome Spring Data! | Oliver Gierke
JAX London
 
Keynote | The Rise and Fall and Rise of Java | James Governor
Keynote | The Rise and Fall and Rise of Java | James Governor
JAX London
 
Java Tech & Tools | OSGi Best Practices | Emily Jiang
Java Tech & Tools | OSGi Best Practices | Emily Jiang
JAX London
 
Java Tech & Tools | Beyond the Data Grid: Coherence, Normalisation, Joins and...
Java Tech & Tools | Beyond the Data Grid: Coherence, Normalisation, Joins and...
JAX London
 
Java Tech & Tools | Big Blobs: Moving Big Data In and Out of the Cloud | Adri...
Java Tech & Tools | Big Blobs: Moving Big Data In and Out of the Cloud | Adri...
JAX London
 
Java Tech & Tools | Social Media in Programming in Java | Khanderao Kand
Java Tech & Tools | Social Media in Programming in Java | Khanderao Kand
JAX London
 
Java Tech & Tools | Just Keep Passing the Message | Russel Winder
Java Tech & Tools | Just Keep Passing the Message | Russel Winder
JAX London
 
Java Tech & Tools | Grails in the Java Enterprise | Peter Ledbrook
Java Tech & Tools | Grails in the Java Enterprise | Peter Ledbrook
JAX London
 
Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sande...
Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sande...
JAX London
 
Java EE | Apache TomEE - Java EE Web Profile on Tomcat | Jonathan Gallimore
Java EE | Apache TomEE - Java EE Web Profile on Tomcat | Jonathan Gallimore
JAX London
 
Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...
Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...
JAX London
 
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
JAX London
 
Java Core | Modern Java Concurrency | Martijn Verburg & Ben Evans
Java Core | Modern Java Concurrency | Martijn Verburg & Ben Evans
JAX London
 
Java Core | Concurrency in the Java Language and Platform | Fredrik Ohrstrom
Java Core | Concurrency in the Java Language and Platform | Fredrik Ohrstrom
JAX London
 

Recently uploaded (20)

cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Safe Software
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
 
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
 
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Safe Software
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
 
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
 

Android | Busy Java Developers Guide to Android: UI | Ted Neward

  • 1. Busy Android Developer's Guide to UI Ted Neward Neward & Associates http://www.tedneward.com | [email protected]
  • 2. Credentials Who is this guy? Architectural Consultant, Neudesic Software Principal, Architect, Consultant and Mentor ask me how I can help your project or your team Microsoft MVP (F#, C#, Architect) JSR 175, 277 Expert Group Member Author Professional F# 2.0 (w/Erickson, et al; Wrox, 2010) Effective Enterprise Java (Addison-Wesley, 2004) C# In a Nutshell (w/Drayton, et all; OReilly, 2003) SSCLI Essentials (w/Stutz, et al; OReilly, 2003) Server-Based Java Programming (Manning, 2000) Blog: http://blogs.tedneward.com Papers: http://www.tedneward.com/writings Twitter: @tedneward
  • 3. Objectives Our goal here today is... ... to get familiar with the various Android UI elements ... to come to understand XML layouts ... to learn how to handle events within Android UIs
  • 4. Activities and Tasks Activity somewhat akin to a web page or screen public class that extends android.app.Activity activities have event methods for override onCreate: activity &quot;constructor&quot; onDestroy: activity &quot;finalizer&quot; onStart/onResume/onPause/onStop/onRestart flow remember to always call up the inheritance chain
  • 5. Activities and Tasks Tasks Tasks are the logical thread of use through Activities usually starting from the Home screen Tasks form a &quot;back stack&quot; of Activity instances &quot;back&quot; button removes the top card, destroys that activity Tasks are distinct from one another a new task creates a new stack of cards this means more than one Activity instance of the same type is possible Tasks cross applications and processes in this respect, Activities are like web pages
  • 6. Viewables View and ViewGroups View is the base class for &quot;widgets&quot; ViewGroup is the base for Composite-patterned containers of other View objects (including other ViewGroup instances) Each Activity can hold one content View most often, this is a ViewGroup, forming a hierarchy Custom Views and ViewGroups you can do them, but it's pretty rare
  • 7. Viewables Widgets (android.widget) &quot;Push Me&quot;: Button, CompoundButton, CheckBox, ImageButton, RadioButton Text: EditText, TextView, NumberPicker, TextSwitcher Graphics: Gallery, ImageSwitcher, ImageView Selectors: RatingBar, SeekBar, Spinner, Switch Time: AnalogClock, DigitalClock, Chronometer, CalendarView, DatePicker, TimePicker Composite: ListView, SlidingDrawer, TabHost Media: MediaController Space (literally, just that--empty space!) ... and a few more
  • 8. Viewables Layouts (android.widget) LinearLayout RelativeLayout TableLayout GridLayout AbsoluteLayout (bad!) FrameLayout (mostly useless!)
  • 9. Viewables Dialogs (android.app) are a special case of Activity AlertDialog (OK/Cancel/Help, etc) ProgressDialog (56 of 100...) DatePickerDialog TimePickerDialog But Dialogs are not Activities Dialogs are always created and displayed as part of (and are &quot;owned&quot; by) an Activity; as such, they are intimately wrapped up in their host Activity's code AlertDialog is the workhorse here
  • 10. Creation Two ways of creating UIs in Android either create UI &quot;by hand&quot; in Java or using XML-based layout (resource) file layout resources are not tied to an Activity; they are just a group of Views laid out in an XML file layout resources can be &quot;inflated&quot; from XML into UI objects (via a system service) Activity.setContentView() is a shortcut way to do this
  • 11. Layout Resources Layout resources are in res/layout directory XML file name corresponds to R.layout.{filename} Root element is (usually) a ViewGroup (Layout class) android: namespace is mandatory element attributes describe &quot;setter&quot; values android:id is critical for manipulation &quot;@+{prefix}/{name}&quot; defines new R.{prefix}.{name} id {prefix} is most often &quot;id&quot; but isn't required IDs don't have to be unique across the entire tree (but usually are)
  • 12. Layout Resources <LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; android:orientation=&quot;vertical&quot; android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;fill_parent&quot;> <ListView android:id=&quot;@+my_team_ids/lstInvitees&quot; android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;wrap_content&quot; android:padding=&quot;6dip&quot; /> <LinearLayout android:orientation=&quot;horizontal&quot; android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;fill_parent&quot; android:gravity=&quot;bottom&quot;> <TextView android:text=&quot;Add:&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot; /> <EditText android:id=&quot;@+my_team_ids/txtNewTeamMember&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot; android:hint=&quot;(Email address)&quot; android:maxLines=&quot;1&quot; /> <ImageButton android:id=&quot;@+my_team_ids/btnInvite&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot; android:src=&quot;@android:drawable/sym_action_chat&quot; /> </LinearLayout> </LinearLayout>
  • 13. Layout Resources Layout resources can be &quot;tuned&quot; like all resources, layouts can be spceialized to particular scenarios screen size: &quot;small&quot;, &quot;normal&quot;, &quot;large&quot;, &quot;xlarge&quot; orientation: &quot;port&quot;, &quot;land&quot; pixel density: &quot;ldpi&quot;, &quot;mdpi&quot;, &quot;hdpi&quot;, &quot;xhdpi&quot;, &quot;nodpi&quot;, &quot;tvdpi&quot; platform version: &quot;v3&quot;, &quot;v4&quot;, &quot;v7&quot;, ... this is one way to customize UI to different device profiles the above qualifiers MUST be in that order see ${SDK}/docs/guide/topics/resources/providing-resources.html
  • 14. Menus Menus Activities can also have menubar items associated with them best used for actions that aren't common or frequent Menus are often defined in layout (res/menu) menu: define a menu, a container for menu items item: define a menuitem, with id, icon and title (text) group: convenience grouping of item elements (invisible)
  • 15. Menus <menu xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;> <item android:id=&quot;@+id/new_game&quot; android:icon=&quot;@drawable/ic_new_game&quot; android:title=&quot;@string/new_game&quot; /> <item android:id=&quot;@+id/help&quot; android:icon=&quot;@drawable/ic_help&quot; android:title=&quot;@string/help&quot; /> </menu>
  • 16. Menus ActionBar (3.0+) A set of menus/menuitems appearing at the top generally only useful for tablets
  • 17. Event-handling Most Views/ViewGroups offer events for code to subscribe to These are called &quot;InputEvents&quot; Most of the time, this is the classic &quot;Listener&quot; idiom View.OnClickListeners can be wired up in the XML layout Most of the time, these are wired up in onCreate()
  • 18. Intents Moving from one Activity to another requires an Intent Intent = Action (verb) + Context (target) easiest Intent is the &quot;launch the Activity&quot; Intent Intent next = new Intent(this, NextActivity.class); startActivity(next);
  • 19. Threading Good Thread hygiene is critical here This is a phone--you don't own the machine! Android isn't quite like Java, and has a slightly different &quot;take&quot; on the threads-and-UI position no blocking behaviors (in general) NO UI modifications from non-UI thread If the UI thread is inactive for more than 5 seconds, bye! Android provides Handlers, which can be sent Messages that will then be processed on the Activity's UI thread Java5 provides a few other constructs as well
  • 20. Wrapping up &quot;What do you know?&quot;
  • 21. Summary Android is a Java-based mobile device framework ... but it's not Java ... and it's not a web app technology ... and it's definitely not Swing or SWT
  • 22. Resources Busy Coder’s Guide to Android Mark Murphy, http://www.commonsware.com Android website http://developer.android.com Presentations by this guy Busy Android Dev's Guide to Persistence Busy Android Dev's Guide to Communication ... and more