Sasha Goldshtein
CTO, SELA Group

@goldshtn
blog.sashag.net

First Steps in Android
Development

© Copyright SELA software...
(Relevant) Android Versions

Froyo

Gingerbread

Honeycomb

•Android 2.2

•Android 2.3.x

•Android 3.x

Ice Cream
Sandwich...
Android Development Environment
Native Android

Xamarin (C#)

• Eclipse/Android
Studio
• Android plugin
for Eclipse (ADT)
...
Hello World

Demo
Project Structure
src
gen
res
layout
values

assets
Android X.X.X
Libraries
AndroidManifest.xml
What Makes an Android
Application?
•
•
•
•

Presentation layer
Derive from Activity
Use Views
Similar to forms in the
desk...
Resources
Resources are non-code application parts
Android resources include
images, strings, simple
values, animations, t...
Layout Resources
Layouts specify the UI
Decouple presentation layer from code
Enable designing UI in XML
Can be referenced...
Code and User Interface
Separation

Strive to define most of the UI in XML files, and
write only code in Java files
Clean ...
Connecting UI to Code

Demo
Localization
Resources make localization easy
Create a language-specific folder structure alongside
the main folder struct...
What Is an Activity?
An activity represents a screen
Using Views to provide UI
Extends the Activity class
To navigate scre...
Creating Activities
Extend the Activity class
The base class presents an empty screen
Encapsulates window display handling...
Multiple Activities
All activities must be declared in the application
manifest
<activity android:name=".SecondaryActivity...
Layouts
Most commonly used layouts
Layout

Description

FrameLayout

Pins child views to the top left corner. Adding multi...
Selectors and Lists
ListView provides a convenient UI
for value selection from a long list
Presents multiple items on scre...
Multiple Activities and ListView

Demo
Xamarin: C# on 3 Billion Devices
Xamarin provides a .NET runtime for iOS and
Android development in C#
Proprietary IDE: Xa...
Xamarin.Android

Demo
Summary
Android development environment
Resources, layouts, views
It’s just another
{language, IDE, UI framework}
The rest...
Questions
Sasha Goldshtein
CTO, SELA Group

@goldshtn
blog.sashag.net
Upcoming SlideShare
Loading in …5
×

First Steps in Android Development with Eclipse and Xamarin

2,791 views

Published on

Presentation from the Toronto TechHub user group on Android development. Introducing basic development concepts with Eclipse and then switching to Xamarin.Android and Visual Studio.

Published in: Technology
  • Be the first to comment

First Steps in Android Development with Eclipse and Xamarin

  1. 1. Sasha Goldshtein CTO, SELA Group @goldshtn blog.sashag.net First Steps in Android Development © Copyright SELA software & Education Labs Ltd. | 14-18 Baruch Hirsch St Bnei Brak, 51202 Israel | www.selagroup.com
  2. 2. (Relevant) Android Versions Froyo Gingerbread Honeycomb •Android 2.2 •Android 2.3.x •Android 3.x Ice Cream Sandwich •Android 4.0 Jelly Bean KitKat •Android 4.1-4.3 •Android 4.4
  3. 3. Android Development Environment Native Android Xamarin (C#) • Eclipse/Android Studio • Android plugin for Eclipse (ADT) • Android SDK • Visual Studio • Xamarin.Android extension • Android SDK
  4. 4. Hello World Demo
  5. 5. Project Structure src gen res layout values assets Android X.X.X Libraries AndroidManifest.xml
  6. 6. What Makes an Android Application? • • • • Presentation layer Derive from Activity Use Views Similar to forms in the desktop world • Worker processes in application • Invisible • Responsible for updating data sources, activities, notifications • Shareable data store • Preferred way to share data across applications Activities Services Content Providers • Message-passing framework • Broadcast messages to target activity/service • Broadcast consumers • Filtered by criteria • Listen to intents that match the criteria • Enables notifications without interrupting the current activity • Device notification area Intents Broadcast Receivers Notifications
  7. 7. 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
  8. 8. 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
  9. 9. 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
  10. 10. Connecting UI to Code Demo
  11. 11. 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
  12. 12. What Is an Activity? An activity represents a screen Using Views to provide UI Extends the Activity class To navigate screens, start a new activity using an intent By default, activities occupy the entire screen Can create semi-transparent/floating activities Last-in-first-out activity stack New activity pushes foreground activity down into stack Navigating back or finishing an activity pops from the stack the previous activity
  13. 13. Creating Activities Extend the Activity class The base class presents an empty screen Encapsulates window display handling functionality User interfaces are created using Views Can create UI from layout or from View-derived instances //Using a layout resource identifier: setContentView(R.layout.main); //Using a View-derived instance: TextView text = new TextView(this); text.setText("New text!"); setContentView(text);
  14. 14. Multiple Activities All activities must be declared in the application manifest <activity android:name=".SecondaryActivity"/> Span a sub-activity using an Intent Intent launch = new Intent(this, SecondaryActivity.class); startActivity(launch);
  15. 15. 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
  16. 16. 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
  17. 17. Multiple Activities and ListView Demo
  18. 18. Xamarin: C# on 3 Billion Devices Xamarin provides a .NET runtime for iOS and Android development in C# Proprietary IDE: Xamarin Studio Full Visual Studio integration
  19. 19. Xamarin.Android Demo
  20. 20. Summary Android development environment Resources, layouts, views It’s just another {language, IDE, UI framework} The rest is just details: data, networking, preferences, styling, …
  21. 21. Questions Sasha Goldshtein CTO, SELA Group @goldshtn blog.sashag.net

×