first steps in android development
DESCRIPTION
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.TRANSCRIPT
© Copyright SELA software & Education Labs Ltd. | 14-18 Baruch Hirsch St Bnei Brak, 51202 Israel | www.selagroup.com
Sasha Goldshtein @goldshtnCTO, SELA Group blog.sashag.netFirst Steps in Android Development
(Relevant) Android Versions
Froyo•Android 2.2
Gingerbread•Android 2.3.x
Honeycomb•Android 3.x
Ice Cream Sandwich•Android 4.0
Jelly Bean•Android 4.1-4.3
KitKat•Android 4.4
Android Development Environment
Android applications are developed using JavaCan use any IDE: IntelliJ, JBuilder, NetBeans, Android StudioOr can use a command line: android create …
The Eclipse IDE is recommendedAndroid plugin for Eclipse (ADT)
Android projects, compilation, deployment, debugging
Android SDKPlatform libraries, sources, samples, emulator images for each Android versionGeneral tools
Demo
Hello World
Project Structure
srcgenres
layoutvalues
assetsAndroid X.X.XLibrariesAndroidManifest.xml
Resources
Resources are non-code application partsAndroid resources include images, strings, simple values, animations, themes, etc.
Best to keep separated/external from codeExternal resources are easier to maintain, upgrade, and manage (…and localize!)
Created under the res folder
Layout Resources
Layouts specify the UIDecouple presentation layer from codeEnable designing UI in XML Can be referenced as any other resource from other layouts
Usually, each layout XML file = view
Layouts
Most commonly used layouts
Multiple layouts can be mixed together
Layout DescriptionFrameLayout 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.
Localization
Resources make localization easyCreate a language-specific folder structure alongside the main folder structureFolder name includes qualifiers
+ res+ values
+ strings.xml
+ values-fr+ strings.xml
+ values-fr-rCA+ strings.xml
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 maintenanceMakes 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
Demo
Connecting UI to Code
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 timeDrop-down overlay of selectable items
Demo
ListView and Adapters
Summary
Android development environmentResources, layouts, viewsIt’s just another{language, IDE, UI framework}The rest is just details: data, networking, preferences, styling, …
QuestionsSasha Goldshtein @goldshtnCTO, SELA Group blog.sashag.net