Presentation from ConFoo 2014 on Android development. Introducing the Android platform, discussing the major components in the ecosystem, and building a basic todo list manager app with Eclipse.
3. Android Development Environment
Android applications are developed using Java
Can use any IDE: IntelliJ, JBuilder, NetBeans, Android
Studio
Or can use a command line: android create …
The Eclipse IDE is recommended
Android plugin for Eclipse (ADT)
Android projects, compilation, deployment, debugging
Android SDK
Platform libraries, sources, samples, emulator images for
each Android version
General tools
6. Resources
Resources are non-code application parts
Android resources include images, strings,
simple values, animations, themes, etc.
Best to keep separated/external from code
External resources are easier to maintain, upgrade,
and manage (…and localize!)
Created under the res folder
7. Layout Resources
Layouts specify the UI
Decouple presentation layer from code
Enable designing UI in XML
Can be referenced as any other resource from other
layouts
Usually, each layout XML file = view
8. Layouts
Most commonly used layouts
Layout
Description
FrameLayout
Pins child views to the top left corner. Adding multiple
children stacks each new child on top of the previous,
with each new view obscuring the last.
LinearLayout
Adds each child view in a straight line, either vertically or
horizontally.
RelativeLayout
Enables defining the positions of each of the child views
relative to each other and the screen boundaries.
TableLayout
Lay out views using a grid of rows and columns.
Multiple layouts can be mixed together
9. Localization
Resources make localization easy
Create a language-specific folder structure alongside
the main folder structure
Folder name includes qualifiers
+ res
+ values
+ strings.xml
+ values-fr
+ strings.xml
+ values-fr-rCA
+ strings.xml
10. Code and User Interface Separation
Strive to define most of the UI in XML files, and
write only code in Java files
Clean code/UI separation provides flexibility and
easy maintenance
Makes it easier to adjust for various types of
hardware devices (similar to resource localization)
UI elements can be manipulated from code
Use findViewById to get UI element instance from
code
12. Selectors and Lists
ListView provides a convenient UI
for value selection from a long list
Presents multiple items on screen
Spinner provides UI for value
selection
Presents only a single value at a time
Drop-down overlay of selectable
items