Introduction_to_Android
Introduction_to_Android
ANDROID
Application Components
Describe the name of android application component and explain
the topic activities in android application ? (slide 3456,7) X (nai
krna ) assignment 2 ma sy krna ha activities wala question
Slide 3
Application
Components (Activities)
(2)
An activity is a class that drives from
Activity
Similar to .NET attributes
Slide 5
Application Components
(Activities) (onCreate)
super.onCreate calls the base class
method
Super is roughly equivalent MyBase in VB
It typically appears as the first statement
in the method
Slide 6
Application Components
(Activities) (onCreate)
(program will stay same for create,set content,super)
Slide 7
Application Components (Layout) (1)
define layout? (separate layout wala ni krna)
Slide 8
Application
Components (Layout)
There are different types of layouts for a
screen
Linear Layout
Relative Layout
Absolute layout
Frame Layout
Scroll View
Table Layout
Lists and Grids
Web
Slide 9
Application
Components(RelativeLayout)
code
RelativeLayout aligns objects relative to an
each other (siblings).
Such as:
Child A to the left of child B
Slide 10
Application Components
(Buttons and Events)
Like a VB button
Text or an icon can appear in the visible
region
They respond to click events (although the
syntax differs).
(DAY 1) done.
http://
developer.android.com/guide/topics/ui/controls/but
ton.html
Slide 11
Application
Components(LinearLayout)
Code of linear layout and relative layout (imp)
screen length
Slide 12
Application Components (Declaring a
Button)
A button has a width and height
The button’s text appears in strings.xml
Slide 13
Application Components (Handling a Click –
Method 1)
Slide 14
Application Components
(Handling a Click – Method
2)
The event handler can also be declared
programmatically using an anonymous
class
The book uses this technique
Slide 15
Application Components (Toast)
Important Question with example(this and next
slide)
Slide 17
Introduction to Input
Controls
question
Button operates like a VB button
TextView operates like a VB TextBox
CheckBox operates like a VB check box
Etc..
All are configured as XML
Slide 18
Strings.xml
Strings literals are stored in the file
strings.xml
Slide 19
Strings.xml
And we reference those strings from the
layout.xml
Slide 20
Resource Files
Question v.v imp
Android R.java is an auto-generated file by
AAPT (Android Asset Packaging Tool) that
contains resource IDs for all the resources of
res/ directory
If you create any component in the
activity_main.xml file, the id for the
corresponding component is automatically
created in this file.
The id can be used in the activity source file
Slide 21
Resource File (Example)
Slide 22
Creating a First Project
(skip)
Click File, New, Project. Select
Android Application Project
Slide 23
Define Application
Parameters (1) (skip)
Don’t use an
old Minimum
Required SDK
Slide 24
Define Application Parameters (1)
(skip)
The Application Name appears in the
store when deployed
The Project Name is only relevant to
Eclipse
The Package Name contains a reverse
domain name
It must be unique and must not be
changed – this is how versioning is
performed
Slide 25
Define Application
Parameters (2) (skip)
Minimum Required SDK contains the
minimum SDK version on which the
application will run
Target SDK contains the desired SDK
version on which the application will run
Compile with contains the SDK version
that will be used to compile the
application
Theme defines basic UI characteristics
Slide 26
Configure Project (skip)
Create activity
Slide 27
Configure Icons (skip)
Configuring
the icons
Just use the
defaults
Slide 28
Create Blank Activity
(skip)
Create the
default activity
This gives you
a blank screen
(form)
(Blank Activity)
Slide 29
Name the Activity and
Layout
Choose the
default values
(skip)
Slide 30
Application Anatomy (1)
(skip)
The file MainActivity.java contains the
java code for the application’s activity
(screen)
Default methods are created too
(onCreate, …)
Slide 31
Application Anatomy (2)
(skip)
The purpose of AndroidManifest.xml is
similar to web.config or app.config
Simply put, it describes the application
Slide 32
Application Anatomy (3)
(skip)
The folder values\strings.xml contains
the application’s textual content
Slide 33
Application Anatomy (4)
(skip)
The file activity_main.xml contains the
XML code that describes the user
interface layout
Slide 34
Setting up the Emulator
(1) (skip)
We can run programs via an emulator or
directly attached to a physical device
Using windows, you might need the driver
from the device manufacturer
Slide 35
Setting up the Emulator
(2)
(skip)
Click Window, Android Device
Manager
Click Create to create the new device
I suggest the following settings
Slide 36
Setting up the Emulator
(3)
(skip)
Under Windows set the memory to no
more than 512MB
Slide 37
Setting up the Emulator
(3)
(skip)
Slide 38
Starting the Emulator
(skip)
Set the display
characteristics
Note that it takes a while
to start the emulator
Slide 39
Running Hello
World (skip)
The emulator
should start and
be rendered
Again, it takes a while to
start
Slide 40
Running Hello World (5)
(skip)
Now run the
application
Slide 41
Guidelines for
Running on a Native Host
(1)
First, plug the device in
If running Windows, you will likely need
a device driver
(skip)
Slide 42
References
http://
developer.android.com/tools/extras/oem
-usb.html
Slide 43