Mobile Technology: Android Apps Development #2
Mobile Technology: Android Apps Development #2
Mobile Technology: Android Apps Development #2
TECHNOLOGY
ANDROID APPS
DEVELOPMENT
#2
2
Objectives
In this chapter, you learn to:
Develop a user interface using the TextView,
ImageView, and Button controls
Create an Android project that includes a
Button event
Select a Linear of Relative layout for the user
interface
Create multiple Android Activities
Add activities to the Android Manifest file
Add a Java class file
3
Objectives
Write code using the onCreate method
Display content using the setContentView
command
Open a second screen using a Button event
handler
Use an OnClickListener to detect user interaction
Launch a second screen using a startActivity
method
Correct errors in Java code
Run the completed app in the emulator
4
Creating Activities
Each screen is considered an activity
Constructed using XML layout files and a Java class
Creating an XML Layout file
All layout files are placed in the res/layout directory
Adding a Class File
A class describes a group of objects and serves as a
blueprint, or template, for creating those objects
An object is a specific, concrete instance of a class
When you create an object, you instantiate it;
meaning you define one particular variation of the
object
15
Creating
Activities
16
Code Syntax:
Button b=(Button)findViewById(R.id.btnRecipe);
22
Summary
Linear layouts arrange screen components in a
vertical column or horizontal row
Relative layouts arrange components freely on
the screen
Text Property and TextSize property are used
when creating text
To display graphics (pictures and icons), use the
ImageView control
An Activity is when the app makes contact with
the user and is a core component of the app
27
Summary
Each screen in your app is an Activity
Every app has an Android Manifest file
containing the name of the app and a list of
each activity
When an app has more than one activity, it
must have an intent so the app can navigate
among multiple activities
A method is a set of Java statements included
in a Java class
The onCreate method initializes an Activity
28
Summary
The setContentView command displays the
content on the screen
Tapping or clicking a button invokes the event
listener and runs the code in that button
Use the startActivity() method to start an
Activity in an app that has multiple Activities
The intent contains a context - initiating Activity
class is making the request - and the name of
the Activity
Red error icons and red curly lines indicate
errors