SlideShare una empresa de Scribd logo
1 de 64
Unit-2
 App components are the essential building blocks of
an Android app. Each component is an entry point
through which the system or a user can enter your
app. Some components depend on others.
 There are four different types of app components:
 Activities: They dictate the UI and handle the user
interaction to the smart phone screen.
 Services: They handle background processing
associated with an application.
 Broadcast receivers: They handle communication
between Android OS and applications.
 Content providers: They handle data and database
management issues.
Android - Application Components
 An activity represents a single screen with a user
interface, in-short Activity performs actions on the
screen.
 For example, an email application might have one
activity that shows a list of new emails, another
activity to compose an email, and another activity for
reading emails.
 If an application has more than one activity, then one
of them should be marked as the activity that is
presented when the application is launched.
 An activity is implemented as a subclass
of Activity class as follows −
 public class MainActivity extends Activity { }
Activity
4
Android Components: Activities
An Activity corresponds to a single
screen of the Application.
An Application can be composed of
multiples screens (Activities).
The Home Activity is shown when the
user launches an application.
Different activities can exhange
information one with each other.
Hello
World!
Android
HelloWorld
Button1
package com.example.helloworld;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
6
Android Components: Activities
Each activity is composed by a list of graphics
components.
Some of these components (also called Views) can
interact with the user by handling events (e.g. Buttons).
Two ways to build the graphic interface:
7
Example:
< TextView
android.text=@string/hell
o”
android:textcolor=@color/
blue
android:layout_width=“fil
l_parent”
android:layout_height=“wr
ap_content” />
< Button
android.id=“@+id/Button01
”
android:textcolor=“@color
/blue”
android:layout_width=“fil
l_parent”
android:layout_height=“wr
ap_content” />
Example:
Button button=new
Button (this);
TextView text= new
TextView();
text.setText(“Hello
world”);
DECLARATIVE APPROACH PROGRAMMATIC APPROACH
8
Android Components: Activities
Android applications typically use both the approaches!
DECLARATIVE APPROACH
PROGRAMMATIC APPROACH
Define the Application layouts
and resources used by the
Application (e.g. labels).
Manages the events, and
handles the interaction with
the user.
XML Code
Java Code
Android Activity Life cycle
 As a user navigates through the app, Activity instances in your app transition through
different stages in their life-cycle. The Activity class provides a number of callbacks
that allow the activity to know that a state has changed: that the system is creating,
stopping, or resuming an activity, or destroying the process in which the activity
resides.
 The Activity class defines the following call backs i.e. events. User need not
implement all the callbacks methods.
 Android Activity Lifecycle is controlled by 7 methods of android.app.Activity class
 Android initiates the program within an activity with a call to
 onCreate() callback method, called when the activity is first created.
 onStart(): This callback method is called when the activity becomes visible to the
user.
 onResume(): The activity is in the foreground and the user can interact with it.
 onPause(): Activity is partially obscured by another activity. Another activity that’s in
the foreground is semi-transparent. The paused activity does not receive user input
and cannot execute any code.
 onStop(): The activity is completely hidden and not visible to the user.
 onRestart(): From the Stopped state, the activity either comes back to interact with
the user or the activity is finished running .If the activity comes back, the system
invokes onRestart()
 onDestroy(): Activity is destroyed and removed from the memory.
 When you open the app it will go through
below states:
onCreate() –> onStart() –> onResume()
 When you press the back button and exit the app
onPaused() — > onStop() –> onDestory()
 When you press the home button
onPaused() –> onStop()
 If a phone is ringing and user is using the app
onPause() –> onResume()
 A service is a component that runs in the background
to perform long-running operations.
 For example, a service might play music in the
background while the user is in a different
application, or it might fetch data over the network
without blocking user interaction with an activity.
 There are two types of services local and remote.
Local service is accessed from within the application
whereas remote service is accessed remotely from
other applications running on the same device.
 A service is implemented as a subclass of Service class
as follows −
 public class MyService extends Service { }
Services
13
Android Components: Services
Services: like Activities, but run in background and do
not provide an user interface.
Used for non-interactive tasks (e.g. networking).
 Service life-time composed of 3 states:
Starting Destroyed
Running
(on background)
onCreate()
onStart()
onDestroy()
 UnBound Service:
 1.Basically used for long repetitive task.
 2.startService() is the method use to start unbound service.
 3.stopService() is the method use to stop explicitly.
 4.It is independent of the component from which it starts.

 Bound Service:
 1.Basically used for long repetitive task but bound with the
component.
 2.starts by bindService().
 3.unbindService() is the method use to stop explicitly.
 4.It is dependent of the component from which it starts
 5.bound service offers a client-server interface that allows
components to interact with the service, send requests, get results.

 Broadcast Receivers simply respond to broadcast
messages from other applications or from the system.
 For example, applications can also initiate broadcasts
to let other applications know that some data has
been downloaded to the device and is available for
them to use, so this is broadcast receiver who will
intercept this communication and will initiate
appropriate action.
 A broadcast receiver is implemented as a subclass
of BroadcastReceiver class and each message is
broadcaster as an Intent object.
 public class MyReceiver extends BroadcastReceiver {
public void onReceive(context,intent){} }
Broadcast Receivers
17
Android Components: Broadcast Receivers
Publish/Subscribe
paradigm
Broadcast
Receivers: An
application can be
signaled of
external events.
Notification types:
Call incoming, SMS
delivery, Wifi
network detected,
etc
 A content provider component supplies data from
one application to others on request.
 Such requests are handled by the methods of
the ContentResolver class.
 The data may be stored in the file system, the
database or somewhere else entirely.
 A content provider is implemented as a subclass
of ContentProvider class and must implement a
standard set of APIs that enable other applications to
perform transactions.
 public class MyContentProvider extends
ContentProvider { public void onCreate(){} }
Content Providers
S.No Components & Description
1
Fragments
Represents a portion of user interface in an Activity.
2
Views
UI elements that are drawn on-screen including buttons, lists forms
etc.
3
Layouts
View hierarchies that control screen format and appearance of the
views.
4
Intents
Messages wiring components together or to invoke components.
5
Resources
External elements, such as strings, constants and drawable pictures.
6
Manifest
Configuration file for the application.
Additional Components
 A fragment has its own layout and its own behaviour with
its own life cycle callbacks.
 You can add or remove fragments in an activity while the
activity is running.
 You can combine multiple fragments in a single activity to
build a multi-pane UI.
 A fragment can be used in multiple activities.
 Fragment life cycle is closely related to the life cycle of its
host activity which means when the activity is paused, all
the fragments available in the activity will also be stopped.
 A fragment can implement a behaviour that has no user
interface component.
 Fragments were added to the Android API in Honeycomb
version of Android which API version 11.
Create Android Application
When you click on Android studio icon, it will show screen
as shown below
 start your application development by calling start a
new android studio project. in a new installation
frame should ask Application name, package
information and location of the project.−

 After entered application name, it going to be called
select the form factors your application runs on, here
need to specify Minimum SDK.
 The next level of installation should contain selecting
the activity to mobile, it specifies the default layout
for Applications.
Provide the Activity Name and click finish.
 At the final stage it going to be open development
tool to write the application code.
Anatomy of Android Application
 Java file contains
 (1) Activity is a java class that creates and default window on the
screen where we can place different components such as Button,
EditText, TextView, Spinner etc. It is like the Frame of Java AWT.
 It provides life cycle methods for activity such as onCreate, onStop,
OnResume etc.
 (2) The onCreate method is called when Activity class is first
created.
 (3) The setContentView(R.layout.activity_main) gives information
about our layout resource. Here, our layout resources are defined in
activity_main.xml file.
 This is the actual application file which ultimately gets converted to
a Dalvik executable and runs your application.
 Generated R.java file
 It is the auto-generated file that contains IDs for all the resources of
res directory.
 It is generated by aapt(Android Asset Packaging Tool). Whenever
you create any component on activity_main, a corresponding ID is
created in the R.java file which can be used in the Java Source file
later.
 The Main Activity File
 The main activity code is a Java file MainActivity.java. This is the
actual application file which ultimately gets converted to a Dalvik
executable and runs your application. Following is the default code
generated by the application wizard for Hello World! Application.
package com.example.helloworld;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
 Here, R.layout.activity_main refers to the activity_main.xml file
located in the res/layout folder. The onCreate() method is one of
many methods that are figured when an activity is loaded.
 APK File(android package)
 An apk file is created by the framework automatically. If
you want to run the android application on the mobile,
transfer and install it.
 Resources
 It contains resource files including activity_main, strings,
styles etc.
 res/drawable-hdpi: This is a directory for drawable objects
that are designed for high-density screens
 res/layout: This is a directory for files that define your app's
user interface.
 res/values: This is a directory for other various XML files
that contain a collection of resources, such as strings and
colours definitions.
 The Manifest File
 Whatever component you develop as a part of your
application, you must declare all its components in
a manifest.xml which resides at the root of the application
project directory.
 This file works as an interface between Android OS and
your application, so if you do not declare your component
in this file, then it will not be considered by the OS.
 Following is the list of tags which you will use in your
manifest file to specify different Android application
components −
 <activity>elements for activities
 <service> elements for services
 <receiver> elements for broadcast receivers
 <provider> elements for content providers
MyProject/
app/
manifest/
AndroidManifest.xml
java/
MyActivity.java
res/
drawable/
icon.png
layout/
activity_main.xml
info.xml
values/
strings.xml
anim/
XML files that define property animations. They are saved in res/anim/ folder and accessed from the
R.anim class.
color/
XML files that define list of colors. They are saved in res/color/ and accessed from the R.color class.
drawable/
Image files like .png, .jpg, .gif or XML files that are compiled into bitmaps, state lists, shapes, animation
drawable. They are saved in res/drawable/ and accessed from the R.drawable class.
Resource in Android Studio
 layout/
 XML files that define a user interface layout. They are saved in res/layout/ and accessed
from the R.layout class.
 menu/
 XML files that define application menus, such as an Options Menu, Context Menu, or Sub
Menu. They are saved in res/menu/ and accessed from the R.menu class.
 raw/
 Arbitrary files to save in their raw form. You need to call Resources.openRawResource()
with the resource ID, which is R.raw.filename to open such raw files.
 values/
 XML files that contain simple values, such as strings, integers, and colors. For example, here
are some filename conventions for resources you can create in this directory −
 arrays.xml for resource arrays, and accessed from the R.array class.
 integers.xml for resource integers, and accessed from the R.integer class.
 bools.xml for resource boolean, and accessed from the R.bool class.
 colors.xml for color values, and accessed from the R.color class.
 dimens.xml for dimension values, and accessed from the R.dimen class.
 strings.xml for string values, and accessed from the R.string class.
 styles.xml for styles, and accessed from the R.style class.
 A View is a simple building block of a user interface.
 It can be TextView, EditText, or even a button.
 It occupies the area on the screen in a rectangular area
and is responsible for drawing and event handling
 View is a superclass of all the graphical user interface
components.
 The use of a view is to draw content on the screen of the
user’s Android device.
 TextView Date Picker
 RadioButton CheckBox buttons
 Image View EditText
 Button Image Button
What is Android View
 A View Group is a subclass of the View Class and can be
considered as a superclass of Layouts.
 It provides an invisible container to hold the views or
layouts.
 it can be understood as a special view that can hold other
views that are often known as a child view.
 Commonly used subclasses for ViewGroup:
 LinearLayout
 RelativeLayout
 FrameLayout
 GridView
 ListView
Android View Group
 layouts which are subclasses of ViewGroup class and a
typical layout defines the visual structure for an
Android user interface .
 User can declare your layout using simple XML
file main_layout.xml which is located in the res/layout
folder of your project.
 A layout may contain any type of widgets such as
buttons, labels, textboxes, and so on.
Android - UI Layouts
 android:id: It uniquely identifies the Android Layout.
 android:layout_height: It sets the height of the layout.
 android:layout_width: It sets the width of the layout.
 android:layout_gravity: It sets the position of the child view.
 android:layout_marginTop: It sets the margin of the from the
top of the layout.
 android:layout_marginBottom: It sets the margin of the from
the bottom of the layout.
 android:layout_marginLeft: It sets the margin of the from the
left of the layout.
 android:layout_marginRight: It sets the margin of the from the
right of the layout.
 android:layout_x: It specifies the x coordinates of the layout.
 android:layout_y: It specifies the y coordinates of the layout.
Attributes of Layout in Android
 Android LinearLayout is a view group that aligns all
children in either vertically or horizontally.
 A vertical layout has a column of Views, whereas in a
horizontal layout there is a row of Views.
 It supports a weight attribute for each child View that can
control the relative size of each child
View within the available space.
 android:orientation:This specifies
the direction of arrangement and
you will use "horizontal" for a row, “
vertical" for a column.
The default is horizontal.
LinearLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="right"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button2"
android:id="@+id/button2"
android:background="#0e7d0d" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1"
android:id="@+id/button"
android:background="#761212" />
</LinearLayout>
 RelativeLayout enables you to specify how child views are positioned
relative to each other. The position of each view can be specified as relative
to sibling elements or relative to the parent.
 android:id:This is the ID which uniquely identifies the layout.
 android:gravity:This specifies how an object should position its content, on
both the X and Y axes. Possible values are top, bottom, left, right, center,
center_vertical, center_horizontal etc.
Properties:android:layout_alignParentTop
android:layout_above,
android:layout_marginBottom
android:layout_centerHorizontal
android:layout_alignBottom
android:layout_marginTop
android:layout_alignParentBottom
android:layout_centerVertical
android:layout_toRightOf
RelativeLayout
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/re
s/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SIGN IN"
android:id="@+id/textView3"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:id="@+id/userName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="110dp"
android:text="UserName:"/>
<TextView
android:id="@+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/userName""
android:text="Password:"/>
<EditText
android:id="@+id/edt_userName"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_marginTop="100dp"
android:layout_toRightOf="@+id/userName"
android:hint="User Name" />
<EditText
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/password"
android:hint="Password" />
<Button
android:id="@+id/btnLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/password"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:text="Login"/>
</RelativeLayout>
 Frame Layout is designed to block out an area on the
screen to display a single item.
 FrameLayout should be used to hold a single child view.
 By default the position is the top-left corner, though the
gravity attribute can be used to alter its locations.
 android:foreground:This defines the drawable to draw
over the content and possible values may be a color value,
in the form of "#rgb", "#rrggbb”.
 android:foregroundGravity:Defines the gravity to apply to
the foreground drawable. The gravity defaults to fill.
Possible values are top, bottom, left, right, center,
center_vertical, center_horizontal etc.
FrameLayout
Frame layout
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
>
<TextView android:text=“Kristu"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text=“Jayanti"
android:layout_gravity="top|right" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text=“College"
android:layout_gravity="top|center_horizontal" />
<TextView android:text=“BCA"
android:layout_gravity="left|center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text=“A Sec"
android:layout_gravity="right|center_vertical" />
</FrameLayout>
 Android TableLayout going to be arranged groups of
views into rows and columns.
 We use the <TableRow> element to build a row in the
table. Each row has zero or more cells;
 each cell can hold one View object.
 TableLayout containers do not display
border lines for their rows, columns, or cells.
TableLayout
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:text=“Welcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1" />
</TableRow>
<TableRow>
<TextView
android:text="First Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column=“0" />
</TableRow>
<TableRow>
<TextView
android:text="Last Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column=“0" />
</TableRow>
</TableLayout>
 An Absolute Layout lets you specify exact locations
(x/y coordinates) of its children.
 Absolute layouts are less flexible and harder to
maintain than other types of layouts without absolute
positioning.
 android:layout_x:This specifies the x-coordinate of
the view.
 android:layout_y:This specifies
the y-coordinate of the view.
Absolute Layout
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="OK"
android:layout_x="50px"
android:layout_y="361px" />
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="Cancel"
android:layout_x="225px"
android:layout_y="361px" />
</AbsoluteLayout>
 A TextView displays text to the user and optionally allows them
to edit it.
 A TextView is a complete text editor, however the basic class is
configured to not allow editing.
 TextView code in XML:
<TextView android:id="@+id/simpleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Android" />
 TextView code in JAVA:
 TextView textView = (TextView) findViewById(R.id.textView);
 textView.setText("Android"); //set text for text view
TextView
1 android:id
This is the ID which uniquely identifies the control.
2 android:capitalize
If set, specifies that this TextView has a textual input method and should automatically
capitalize what the user types.
•Don't automatically capitalize anything - 0
•Capitalize the first word of each sentence - 1
•Capitalize the first letter of every word - 2
•Capitalize every character - 3
3 android:cursorVisible
Makes the cursor visible (the default) or invisible. Default is false.
4 android:editable
If set to true, specifies that this TextView has an input method.
5 android:fontFamily
Font family (named by string) for the text.
6 android:gravity
Specifies how to align the text by the view's x- and/or y-axis when the text is smaller
than the view.
7 android:hint
Hint text to display when the text is empty.
8 android:inputType
The type of data being placed in a text field. Phone, Date, Time, Number, Password etc.
13 android:password
Whether the characters of the field are displayed as password dots instead of
themselves. Possible value either "true" or "false".
14 android:phoneNumber
If set, specifies that this TextView has a phone number input method. Possible value either
"true" or "false".
15 android:text
Text to display.
16 android:textAllCaps
Present the text in ALL CAPS. Possible value either "true" or "false".
17 android:textColor
Text color. May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or
"#aarrggbb".
21 android:textSize
Size of the text. Recommended dimension type for text is "sp" for scaled-pixels (example:
15sp).
22 android:textStyle
Style (bold, italic, bolditalic) for the text. You can use or more of the following values
separated by '|'.
•normal - 0
•bold - 1
•italic - 2
23 android:typeface
Typeface (normal, sans, serif, monospace) for the text. You can use or more of the
following values separated by '|'.
•normal - 0
•sans - 1
•serif - 2
•monospace - 3
 A EditText is an overlay over TextView that configures
itself to be editable. It is the predefined subclass of
TextView that includes rich editing capabilities.

EditText
Styles of edit text
1 android:autoText
If set, specifies that this TextView has a textual input method and
automatically corrects some common spelling errors.
2 android:drawableBottom
This is the drawable to be drawn below the text.
3 android:drawableRight
This is the drawable to be drawn to the right of the text.
4 android:editable
If set, specifies that this TextView has an input method.
5 android:text
This is the Text to display.
Inherited from android.widget.TextView Class
1 android:background
This is a drawable to use as the background.
2 android:contentDescription
This defines text that briefly describes content of the view.
3 android:id
This supplies an identifier name for this view.
4 android:onClick
This is the name of the method in this View's context to invoke when
the view is clicked.
5 android:visibility:This controls the initial visibility of the view.
Inherited from android.view.View Class
 A AutoCompleteTextView is a view that is similar to
EditText, except that it shows a list of completion
suggestions automatically while the user is typing.
 The list of suggestions is displayed in drop down menu.
The user can choose an item from there to replace the
content of edit box with.
 The Threshold property of AutoCompleteTextView is
used to define the minimum number of characters the
user must type to see the list of suggestions.
AutoCompleteTextView
1
android:completionHint
This defines the hint displayed in the drop down menu.
2
android:completionThreshold
This defines the number of characters that the user must type before
completion suggestions are displayed in a drop down menu.
3
android:dropDownAnchor
This is the View to anchor the auto-complete dropdown to.
4
android:dropDownHeight
This specifies the basic height of the dropdown.
5
android:dropDownHorizontalOffset
The amount of pixels by which the drop down should be offset
horizontally.
6
android:dropDownSelector
This is the selector in a drop down list.
7
android:dropDownVerticalOffset
The amount of pixels by which the drop down should be offset vertically.
8
android:dropDownWidth
This specifies the basic width of the dropdown.
 A Button is a Push-button which can be pressed, or clicked, by the user to perform an
action.
 Buttons in android will contain a text or an icon or both and perform an action when
the user touches it.
 There are different type of buttons available to use based on the requirements, those
are ImageButton, ToggleButton, RadioButton.
 In html file include
 android:onClick="addOperation“
 In java file include
 /** Called when the user touches the button */
public void addOperation(View view) {
// Do something in response to the button click
}
 After oncreate include:
 Button btnAdd = (Button)findViewById(R.id.addBtn);
btnAdd.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
 // Do something in response to button click
}
});
}
Button
1 android:autoText
If set, specifies that this TextView has a textual input method and
automatically corrects some common spelling errors.
2 android:drawableBottom
This is the drawable to be drawn below the text.
3 android:drawableRight
This is the drawable to be drawn to the right of the text.
4 android:editable
If set, specifies that this TextView has an input method.
5 android:text
This is the Text to display.
Inherited from android.widget.TextView Class
1 android:contentDescription
This defines text that briefly describes content of the view.
2 android:id
This supplies an identifier name for this view.
3 android:onClick
This is the name of the method in this View's context to
invoke when the view is clicked.
4 android:visibility
This controls the initial visibility of the view.
Inherited from android.view.View Class
 Android Image Button
 In android, Image Button is a user interface control that is used to display a button
with an image to perform an action when the user clicks or tap on it.
 Generally, the Image button in android looks similar as regular Button and perform the
actions same as regular button but only difference is for image button we will add an
image instead of text.
 Android Toggle Button
 In android, Toggle Button is a user interface control that is used to display ON
(Checked) or OFF (Unchecked) states as a button with a light indicator.
 Android CheckBox
 In android, Checkbox is a two-states button that can be either checked or unchecked.
 use check-boxes when presenting users with a group of selectable options that are
not mutually exclusive.
 Android Radio Button
 In android, Radio Button is a two-states button that can be either checked or
unchecked and it cannot be unchecked once it is checked.
 Android Radio Group
 In android, Radio Group is used to group one or more
radio buttons into separate groups based on our
requirements.
 In case if we group radio buttons using the radio
group, at a time only one item can be selected from
the group of radio buttons.
 Android ProgressBar
 In android, ProgressBar is a user interface control
which is used to indicate the progress of an
operation.
` getMax()
This method returns the maximum value of the progress.
2 incrementProgressBy(int diff)
This method increments the progress bar by the difference of value passed
as a parameter.
3 setIndeterminate(boolean indeterminate)
This method sets the progress indicator as determinate or indeterminate.
4 setMax(int max)
This method sets the maximum value of the progress dialog.
5 setProgress(int value)
This method is used to update the progress dialog with some specific value.
 Android Spinner
 In android, Spinner is a drop-down list which allows a
user to select one value from the list.
 Android TimePicker
 In android, TimePicker is a widget for selecting the
time of day, either in 24-hour or AM/PM mode.
 Android DatePicker
 In android, DatePicker is a widget for selecting a date
consisting of day, month and year

Más contenido relacionado

La actualidad más candente

Multiple Activity and Navigation Primer
Multiple Activity and Navigation PrimerMultiple Activity and Navigation Primer
Multiple Activity and Navigation PrimerAhsanul Karim
 
Android apps development
Android apps developmentAndroid apps development
Android apps developmentRaman Pandey
 
Android Screen Containers & Layouts
Android Screen Containers & LayoutsAndroid Screen Containers & Layouts
Android Screen Containers & LayoutsVijay Rastogi
 
Day: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentDay: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentAhsanul Karim
 
Android Tutorial
Android TutorialAndroid Tutorial
Android TutorialFun2Do Labs
 
"Android" mobilių programėlių kūrimo įvadas #2
"Android" mobilių programėlių kūrimo įvadas #2"Android" mobilių programėlių kūrimo įvadas #2
"Android" mobilių programėlių kūrimo įvadas #2Tadas Jurelevičius
 
Beginning android
Beginning android Beginning android
Beginning android Igor R
 
Marakana Android User Interface
Marakana Android User InterfaceMarakana Android User Interface
Marakana Android User InterfaceMarko Gargenta
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidDenis Minja
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI WidgetsAhsanul Karim
 
Ui layout (incomplete)
Ui layout (incomplete)Ui layout (incomplete)
Ui layout (incomplete)Ahsanul Karim
 

La actualidad más candente (20)

Android UI Fundamentals part 1
Android UI Fundamentals part 1Android UI Fundamentals part 1
Android UI Fundamentals part 1
 
Multiple Activity and Navigation Primer
Multiple Activity and Navigation PrimerMultiple Activity and Navigation Primer
Multiple Activity and Navigation Primer
 
Android apps development
Android apps developmentAndroid apps development
Android apps development
 
Android development session 3 - layout
Android development   session 3 - layoutAndroid development   session 3 - layout
Android development session 3 - layout
 
Training android
Training androidTraining android
Training android
 
Android xml-based layouts-chapter5
Android xml-based layouts-chapter5Android xml-based layouts-chapter5
Android xml-based layouts-chapter5
 
Android Screen Containers & Layouts
Android Screen Containers & LayoutsAndroid Screen Containers & Layouts
Android Screen Containers & Layouts
 
Android layouts
Android layoutsAndroid layouts
Android layouts
 
Day: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentDay: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application Development
 
Android Tutorial
Android TutorialAndroid Tutorial
Android Tutorial
 
Ppt 2 android_basics
Ppt 2 android_basicsPpt 2 android_basics
Ppt 2 android_basics
 
"Android" mobilių programėlių kūrimo įvadas #2
"Android" mobilių programėlių kūrimo įvadas #2"Android" mobilių programėlių kūrimo įvadas #2
"Android" mobilių programėlių kūrimo įvadas #2
 
Beginning android
Beginning android Beginning android
Beginning android
 
Marakana Android User Interface
Marakana Android User InterfaceMarakana Android User Interface
Marakana Android User Interface
 
Android UI
Android UIAndroid UI
Android UI
 
Android UI Patterns
Android UI PatternsAndroid UI Patterns
Android UI Patterns
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_android
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI Widgets
 
Ui layout (incomplete)
Ui layout (incomplete)Ui layout (incomplete)
Ui layout (incomplete)
 
01 08 - graphical user interface - layouts
01  08 - graphical user interface - layouts01  08 - graphical user interface - layouts
01 08 - graphical user interface - layouts
 

Similar a Unit2

Android app fundamentals
Android app fundamentalsAndroid app fundamentals
Android app fundamentalsAmr Salman
 
Android application development
Android application developmentAndroid application development
Android application developmentMd. Mujahid Islam
 
Nativa Android Applications development
Nativa Android Applications developmentNativa Android Applications development
Nativa Android Applications developmentAlfredo Morresi
 
Android building blocks and application life cycle-chapter3
Android building blocks and application life cycle-chapter3Android building blocks and application life cycle-chapter3
Android building blocks and application life cycle-chapter3Dr. Ramkumar Lakshminarayanan
 
Android application fundamentals
Android application fundamentalsAndroid application fundamentals
Android application fundamentalsJohn Smith
 
android_mod_3.useful for bca students for their last sem
android_mod_3.useful for bca students for their last semandroid_mod_3.useful for bca students for their last sem
android_mod_3.useful for bca students for their last semaswinbiju1652
 
Android 101 Session @thejunction32
Android 101 Session @thejunction32Android 101 Session @thejunction32
Android 101 Session @thejunction32Eden Shochat
 
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxxMAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx34ShreyaChauhan
 
Android terminologies
Android terminologiesAndroid terminologies
Android terminologiesjerry vasoya
 
Mobile Application Guideline | Mobile App Development Company
Mobile Application Guideline | Mobile App Development Company Mobile Application Guideline | Mobile App Development Company
Mobile Application Guideline | Mobile App Development Company Arna Softech Private Limited
 
Mobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfMobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfAbdullahMunir32
 
Hello android world
Hello android worldHello android world
Hello android worldeleksdev
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android DevelopmentAly Abdelkareem
 

Similar a Unit2 (20)

Android app fundamentals
Android app fundamentalsAndroid app fundamentals
Android app fundamentals
 
Android beginners David
Android beginners DavidAndroid beginners David
Android beginners David
 
Android application development
Android application developmentAndroid application development
Android application development
 
Android Development Basics
Android Development BasicsAndroid Development Basics
Android Development Basics
 
Nativa Android Applications development
Nativa Android Applications developmentNativa Android Applications development
Nativa Android Applications development
 
Android building blocks and application life cycle-chapter3
Android building blocks and application life cycle-chapter3Android building blocks and application life cycle-chapter3
Android building blocks and application life cycle-chapter3
 
Android application fundamentals
Android application fundamentalsAndroid application fundamentals
Android application fundamentals
 
android_mod_3.useful for bca students for their last sem
android_mod_3.useful for bca students for their last semandroid_mod_3.useful for bca students for their last sem
android_mod_3.useful for bca students for their last sem
 
Android 101 Session @thejunction32
Android 101 Session @thejunction32Android 101 Session @thejunction32
Android 101 Session @thejunction32
 
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxxMAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
 
Android terminologies
Android terminologiesAndroid terminologies
Android terminologies
 
Mobile testing android
Mobile testing   androidMobile testing   android
Mobile testing android
 
Mobile Application Guideline | Mobile App Development Company
Mobile Application Guideline | Mobile App Development Company Mobile Application Guideline | Mobile App Development Company
Mobile Application Guideline | Mobile App Development Company
 
Mobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfMobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdf
 
Hello android world
Hello android worldHello android world
Hello android world
 
Android Basic- CMC
Android Basic- CMCAndroid Basic- CMC
Android Basic- CMC
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Activity
ActivityActivity
Activity
 
Activity
ActivityActivity
Activity
 
Activity
ActivityActivity
Activity
 

Más de DevaKumari Vijay

Unit 1 computer architecture (1)
Unit 1   computer architecture (1)Unit 1   computer architecture (1)
Unit 1 computer architecture (1)DevaKumari Vijay
 
Unit 2 monte carlo simulation
Unit 2 monte carlo simulationUnit 2 monte carlo simulation
Unit 2 monte carlo simulationDevaKumari Vijay
 
Decisiontree&amp;game theory
Decisiontree&amp;game theoryDecisiontree&amp;game theory
Decisiontree&amp;game theoryDevaKumari Vijay
 
Unit2 network optimization
Unit2 network optimizationUnit2 network optimization
Unit2 network optimizationDevaKumari Vijay
 
Unit 4 simulation and queing theory(m/m/1)
Unit 4  simulation and queing theory(m/m/1)Unit 4  simulation and queing theory(m/m/1)
Unit 4 simulation and queing theory(m/m/1)DevaKumari Vijay
 
Unit 1 introduction to simulation
Unit 1 introduction to simulationUnit 1 introduction to simulation
Unit 1 introduction to simulationDevaKumari Vijay
 
Unit2 montecarlosimulation
Unit2 montecarlosimulationUnit2 montecarlosimulation
Unit2 montecarlosimulationDevaKumari Vijay
 
Unit 4 exceptions and threads
Unit 4 exceptions and threadsUnit 4 exceptions and threads
Unit 4 exceptions and threadsDevaKumari Vijay
 
Unit3 part3-packages and interfaces
Unit3 part3-packages and interfacesUnit3 part3-packages and interfaces
Unit3 part3-packages and interfacesDevaKumari Vijay
 
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arraysUnit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arraysDevaKumari Vijay
 
Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to JavaDevaKumari Vijay
 
Introduction to design and analysis of algorithm
Introduction to design and analysis of algorithmIntroduction to design and analysis of algorithm
Introduction to design and analysis of algorithmDevaKumari Vijay
 

Más de DevaKumari Vijay (20)

Unit 1 computer architecture (1)
Unit 1   computer architecture (1)Unit 1   computer architecture (1)
Unit 1 computer architecture (1)
 
Os ch1
Os ch1Os ch1
Os ch1
 
Unit 1
Unit 1Unit 1
Unit 1
 
Unit 2 monte carlo simulation
Unit 2 monte carlo simulationUnit 2 monte carlo simulation
Unit 2 monte carlo simulation
 
Decisiontree&amp;game theory
Decisiontree&amp;game theoryDecisiontree&amp;game theory
Decisiontree&amp;game theory
 
Unit2 network optimization
Unit2 network optimizationUnit2 network optimization
Unit2 network optimization
 
Unit 4 simulation and queing theory(m/m/1)
Unit 4  simulation and queing theory(m/m/1)Unit 4  simulation and queing theory(m/m/1)
Unit 4 simulation and queing theory(m/m/1)
 
Unit4 systemdynamics
Unit4 systemdynamicsUnit4 systemdynamics
Unit4 systemdynamics
 
Unit 3 des
Unit 3 desUnit 3 des
Unit 3 des
 
Unit 1 introduction to simulation
Unit 1 introduction to simulationUnit 1 introduction to simulation
Unit 1 introduction to simulation
 
Unit2 montecarlosimulation
Unit2 montecarlosimulationUnit2 montecarlosimulation
Unit2 montecarlosimulation
 
Unit 3-Greedy Method
Unit 3-Greedy MethodUnit 3-Greedy Method
Unit 3-Greedy Method
 
Unit 5 java-awt (1)
Unit 5 java-awt (1)Unit 5 java-awt (1)
Unit 5 java-awt (1)
 
Unit 4 exceptions and threads
Unit 4 exceptions and threadsUnit 4 exceptions and threads
Unit 4 exceptions and threads
 
Unit3 part3-packages and interfaces
Unit3 part3-packages and interfacesUnit3 part3-packages and interfaces
Unit3 part3-packages and interfaces
 
Unit3 part2-inheritance
Unit3 part2-inheritanceUnit3 part2-inheritance
Unit3 part2-inheritance
 
Unit3 part1-class
Unit3 part1-classUnit3 part1-class
Unit3 part1-class
 
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arraysUnit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
 
Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to Java
 
Introduction to design and analysis of algorithm
Introduction to design and analysis of algorithmIntroduction to design and analysis of algorithm
Introduction to design and analysis of algorithm
 

Último

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 

Último (20)

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 

Unit2

  • 2.  App components are the essential building blocks of an Android app. Each component is an entry point through which the system or a user can enter your app. Some components depend on others.  There are four different types of app components:  Activities: They dictate the UI and handle the user interaction to the smart phone screen.  Services: They handle background processing associated with an application.  Broadcast receivers: They handle communication between Android OS and applications.  Content providers: They handle data and database management issues. Android - Application Components
  • 3.  An activity represents a single screen with a user interface, in-short Activity performs actions on the screen.  For example, an email application might have one activity that shows a list of new emails, another activity to compose an email, and another activity for reading emails.  If an application has more than one activity, then one of them should be marked as the activity that is presented when the application is launched.  An activity is implemented as a subclass of Activity class as follows −  public class MainActivity extends Activity { } Activity
  • 4. 4 Android Components: Activities An Activity corresponds to a single screen of the Application. An Application can be composed of multiples screens (Activities). The Home Activity is shown when the user launches an application. Different activities can exhange information one with each other. Hello World! Android HelloWorld Button1
  • 5. package com.example.helloworld; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } }
  • 6. 6 Android Components: Activities Each activity is composed by a list of graphics components. Some of these components (also called Views) can interact with the user by handling events (e.g. Buttons). Two ways to build the graphic interface:
  • 7. 7 Example: < TextView android.text=@string/hell o” android:textcolor=@color/ blue android:layout_width=“fil l_parent” android:layout_height=“wr ap_content” /> < Button android.id=“@+id/Button01 ” android:textcolor=“@color /blue” android:layout_width=“fil l_parent” android:layout_height=“wr ap_content” /> Example: Button button=new Button (this); TextView text= new TextView(); text.setText(“Hello world”); DECLARATIVE APPROACH PROGRAMMATIC APPROACH
  • 8. 8 Android Components: Activities Android applications typically use both the approaches! DECLARATIVE APPROACH PROGRAMMATIC APPROACH Define the Application layouts and resources used by the Application (e.g. labels). Manages the events, and handles the interaction with the user. XML Code Java Code
  • 10.  As a user navigates through the app, Activity instances in your app transition through different stages in their life-cycle. The Activity class provides a number of callbacks that allow the activity to know that a state has changed: that the system is creating, stopping, or resuming an activity, or destroying the process in which the activity resides.  The Activity class defines the following call backs i.e. events. User need not implement all the callbacks methods.  Android Activity Lifecycle is controlled by 7 methods of android.app.Activity class  Android initiates the program within an activity with a call to  onCreate() callback method, called when the activity is first created.  onStart(): This callback method is called when the activity becomes visible to the user.  onResume(): The activity is in the foreground and the user can interact with it.  onPause(): Activity is partially obscured by another activity. Another activity that’s in the foreground is semi-transparent. The paused activity does not receive user input and cannot execute any code.  onStop(): The activity is completely hidden and not visible to the user.  onRestart(): From the Stopped state, the activity either comes back to interact with the user or the activity is finished running .If the activity comes back, the system invokes onRestart()  onDestroy(): Activity is destroyed and removed from the memory.
  • 11.  When you open the app it will go through below states: onCreate() –> onStart() –> onResume()  When you press the back button and exit the app onPaused() — > onStop() –> onDestory()  When you press the home button onPaused() –> onStop()  If a phone is ringing and user is using the app onPause() –> onResume()
  • 12.  A service is a component that runs in the background to perform long-running operations.  For example, a service might play music in the background while the user is in a different application, or it might fetch data over the network without blocking user interaction with an activity.  There are two types of services local and remote. Local service is accessed from within the application whereas remote service is accessed remotely from other applications running on the same device.  A service is implemented as a subclass of Service class as follows −  public class MyService extends Service { } Services
  • 13. 13 Android Components: Services Services: like Activities, but run in background and do not provide an user interface. Used for non-interactive tasks (e.g. networking).  Service life-time composed of 3 states: Starting Destroyed Running (on background) onCreate() onStart() onDestroy()
  • 14.
  • 15.  UnBound Service:  1.Basically used for long repetitive task.  2.startService() is the method use to start unbound service.  3.stopService() is the method use to stop explicitly.  4.It is independent of the component from which it starts.   Bound Service:  1.Basically used for long repetitive task but bound with the component.  2.starts by bindService().  3.unbindService() is the method use to stop explicitly.  4.It is dependent of the component from which it starts  5.bound service offers a client-server interface that allows components to interact with the service, send requests, get results. 
  • 16.  Broadcast Receivers simply respond to broadcast messages from other applications or from the system.  For example, applications can also initiate broadcasts to let other applications know that some data has been downloaded to the device and is available for them to use, so this is broadcast receiver who will intercept this communication and will initiate appropriate action.  A broadcast receiver is implemented as a subclass of BroadcastReceiver class and each message is broadcaster as an Intent object.  public class MyReceiver extends BroadcastReceiver { public void onReceive(context,intent){} } Broadcast Receivers
  • 17. 17 Android Components: Broadcast Receivers Publish/Subscribe paradigm Broadcast Receivers: An application can be signaled of external events. Notification types: Call incoming, SMS delivery, Wifi network detected, etc
  • 18.  A content provider component supplies data from one application to others on request.  Such requests are handled by the methods of the ContentResolver class.  The data may be stored in the file system, the database or somewhere else entirely.  A content provider is implemented as a subclass of ContentProvider class and must implement a standard set of APIs that enable other applications to perform transactions.  public class MyContentProvider extends ContentProvider { public void onCreate(){} } Content Providers
  • 19. S.No Components & Description 1 Fragments Represents a portion of user interface in an Activity. 2 Views UI elements that are drawn on-screen including buttons, lists forms etc. 3 Layouts View hierarchies that control screen format and appearance of the views. 4 Intents Messages wiring components together or to invoke components. 5 Resources External elements, such as strings, constants and drawable pictures. 6 Manifest Configuration file for the application. Additional Components
  • 20.  A fragment has its own layout and its own behaviour with its own life cycle callbacks.  You can add or remove fragments in an activity while the activity is running.  You can combine multiple fragments in a single activity to build a multi-pane UI.  A fragment can be used in multiple activities.  Fragment life cycle is closely related to the life cycle of its host activity which means when the activity is paused, all the fragments available in the activity will also be stopped.  A fragment can implement a behaviour that has no user interface component.  Fragments were added to the Android API in Honeycomb version of Android which API version 11.
  • 21.
  • 22. Create Android Application When you click on Android studio icon, it will show screen as shown below
  • 23.  start your application development by calling start a new android studio project. in a new installation frame should ask Application name, package information and location of the project.− 
  • 24.  After entered application name, it going to be called select the form factors your application runs on, here need to specify Minimum SDK.
  • 25.  The next level of installation should contain selecting the activity to mobile, it specifies the default layout for Applications.
  • 26. Provide the Activity Name and click finish.
  • 27.  At the final stage it going to be open development tool to write the application code.
  • 28. Anatomy of Android Application
  • 29.  Java file contains  (1) Activity is a java class that creates and default window on the screen where we can place different components such as Button, EditText, TextView, Spinner etc. It is like the Frame of Java AWT.  It provides life cycle methods for activity such as onCreate, onStop, OnResume etc.  (2) The onCreate method is called when Activity class is first created.  (3) The setContentView(R.layout.activity_main) gives information about our layout resource. Here, our layout resources are defined in activity_main.xml file.  This is the actual application file which ultimately gets converted to a Dalvik executable and runs your application.  Generated R.java file  It is the auto-generated file that contains IDs for all the resources of res directory.  It is generated by aapt(Android Asset Packaging Tool). Whenever you create any component on activity_main, a corresponding ID is created in the R.java file which can be used in the Java Source file later.
  • 30.  The Main Activity File  The main activity code is a Java file MainActivity.java. This is the actual application file which ultimately gets converted to a Dalvik executable and runs your application. Following is the default code generated by the application wizard for Hello World! Application. package com.example.helloworld; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } }  Here, R.layout.activity_main refers to the activity_main.xml file located in the res/layout folder. The onCreate() method is one of many methods that are figured when an activity is loaded.
  • 31.  APK File(android package)  An apk file is created by the framework automatically. If you want to run the android application on the mobile, transfer and install it.  Resources  It contains resource files including activity_main, strings, styles etc.  res/drawable-hdpi: This is a directory for drawable objects that are designed for high-density screens  res/layout: This is a directory for files that define your app's user interface.  res/values: This is a directory for other various XML files that contain a collection of resources, such as strings and colours definitions.
  • 32.  The Manifest File  Whatever component you develop as a part of your application, you must declare all its components in a manifest.xml which resides at the root of the application project directory.  This file works as an interface between Android OS and your application, so if you do not declare your component in this file, then it will not be considered by the OS.  Following is the list of tags which you will use in your manifest file to specify different Android application components −  <activity>elements for activities  <service> elements for services  <receiver> elements for broadcast receivers  <provider> elements for content providers
  • 33. MyProject/ app/ manifest/ AndroidManifest.xml java/ MyActivity.java res/ drawable/ icon.png layout/ activity_main.xml info.xml values/ strings.xml anim/ XML files that define property animations. They are saved in res/anim/ folder and accessed from the R.anim class. color/ XML files that define list of colors. They are saved in res/color/ and accessed from the R.color class. drawable/ Image files like .png, .jpg, .gif or XML files that are compiled into bitmaps, state lists, shapes, animation drawable. They are saved in res/drawable/ and accessed from the R.drawable class. Resource in Android Studio
  • 34.  layout/  XML files that define a user interface layout. They are saved in res/layout/ and accessed from the R.layout class.  menu/  XML files that define application menus, such as an Options Menu, Context Menu, or Sub Menu. They are saved in res/menu/ and accessed from the R.menu class.  raw/  Arbitrary files to save in their raw form. You need to call Resources.openRawResource() with the resource ID, which is R.raw.filename to open such raw files.  values/  XML files that contain simple values, such as strings, integers, and colors. For example, here are some filename conventions for resources you can create in this directory −  arrays.xml for resource arrays, and accessed from the R.array class.  integers.xml for resource integers, and accessed from the R.integer class.  bools.xml for resource boolean, and accessed from the R.bool class.  colors.xml for color values, and accessed from the R.color class.  dimens.xml for dimension values, and accessed from the R.dimen class.  strings.xml for string values, and accessed from the R.string class.  styles.xml for styles, and accessed from the R.style class.
  • 35.  A View is a simple building block of a user interface.  It can be TextView, EditText, or even a button.  It occupies the area on the screen in a rectangular area and is responsible for drawing and event handling  View is a superclass of all the graphical user interface components.  The use of a view is to draw content on the screen of the user’s Android device.  TextView Date Picker  RadioButton CheckBox buttons  Image View EditText  Button Image Button What is Android View
  • 36.  A View Group is a subclass of the View Class and can be considered as a superclass of Layouts.  It provides an invisible container to hold the views or layouts.  it can be understood as a special view that can hold other views that are often known as a child view.  Commonly used subclasses for ViewGroup:  LinearLayout  RelativeLayout  FrameLayout  GridView  ListView Android View Group
  • 37.  layouts which are subclasses of ViewGroup class and a typical layout defines the visual structure for an Android user interface .  User can declare your layout using simple XML file main_layout.xml which is located in the res/layout folder of your project.  A layout may contain any type of widgets such as buttons, labels, textboxes, and so on. Android - UI Layouts
  • 38.  android:id: It uniquely identifies the Android Layout.  android:layout_height: It sets the height of the layout.  android:layout_width: It sets the width of the layout.  android:layout_gravity: It sets the position of the child view.  android:layout_marginTop: It sets the margin of the from the top of the layout.  android:layout_marginBottom: It sets the margin of the from the bottom of the layout.  android:layout_marginLeft: It sets the margin of the from the left of the layout.  android:layout_marginRight: It sets the margin of the from the right of the layout.  android:layout_x: It specifies the x coordinates of the layout.  android:layout_y: It specifies the y coordinates of the layout. Attributes of Layout in Android
  • 39.  Android LinearLayout is a view group that aligns all children in either vertically or horizontally.  A vertical layout has a column of Views, whereas in a horizontal layout there is a row of Views.  It supports a weight attribute for each child View that can control the relative size of each child View within the available space.  android:orientation:This specifies the direction of arrangement and you will use "horizontal" for a row, “ vertical" for a column. The default is horizontal. LinearLayout
  • 41.  RelativeLayout enables you to specify how child views are positioned relative to each other. The position of each view can be specified as relative to sibling elements or relative to the parent.  android:id:This is the ID which uniquely identifies the layout.  android:gravity:This specifies how an object should position its content, on both the X and Y axes. Possible values are top, bottom, left, right, center, center_vertical, center_horizontal etc. Properties:android:layout_alignParentTop android:layout_above, android:layout_marginBottom android:layout_centerHorizontal android:layout_alignBottom android:layout_marginTop android:layout_alignParentBottom android:layout_centerVertical android:layout_toRightOf RelativeLayout
  • 42. <RelativeLayout xmlns:android="http://schemas.android.com/apk/re s/android" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="SIGN IN" android:id="@+id/textView3" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" /> <TextView android:id="@+id/userName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="110dp" android:text="UserName:"/> <TextView android:id="@+id/password" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/userName"" android:text="Password:"/> <EditText android:id="@+id/edt_userName" android:layout_width="fill_parent" android:layout_height="40dp" android:layout_marginTop="100dp" android:layout_toRightOf="@+id/userName" android:hint="User Name" /> <EditText android:layout_width="fill_parent" android:layout_height="40dp" android:layout_centerVertical="true" android:layout_toRightOf="@+id/password" android:hint="Password" /> <Button android:id="@+id/btnLogin" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/password" android:layout_centerHorizontal="true" android:layout_marginTop="20dp" android:text="Login"/> </RelativeLayout>
  • 43.  Frame Layout is designed to block out an area on the screen to display a single item.  FrameLayout should be used to hold a single child view.  By default the position is the top-left corner, though the gravity attribute can be used to alter its locations.  android:foreground:This defines the drawable to draw over the content and possible values may be a color value, in the form of "#rgb", "#rrggbb”.  android:foregroundGravity:Defines the gravity to apply to the foreground drawable. The gravity defaults to fill. Possible values are top, bottom, left, right, center, center_vertical, center_horizontal etc. FrameLayout
  • 45. <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="match_parent" android:layout_width="match_parent" > <TextView android:text=“Kristu" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:text=“Jayanti" android:layout_gravity="top|right" /> <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:text=“College" android:layout_gravity="top|center_horizontal" /> <TextView android:text=“BCA" android:layout_gravity="left|center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:text=“A Sec" android:layout_gravity="right|center_vertical" /> </FrameLayout>
  • 46.  Android TableLayout going to be arranged groups of views into rows and columns.  We use the <TableRow> element to build a row in the table. Each row has zero or more cells;  each cell can hold one View object.  TableLayout containers do not display border lines for their rows, columns, or cells. TableLayout
  • 47. <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:text=“Welcome" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="1" /> </TableRow> <TableRow> <TextView android:text="First Name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column=“0" /> </TableRow> <TableRow> <TextView android:text="Last Name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column=“0" /> </TableRow> </TableLayout>
  • 48.  An Absolute Layout lets you specify exact locations (x/y coordinates) of its children.  Absolute layouts are less flexible and harder to maintain than other types of layouts without absolute positioning.  android:layout_x:This specifies the x-coordinate of the view.  android:layout_y:This specifies the y-coordinate of the view. Absolute Layout
  • 50.  A TextView displays text to the user and optionally allows them to edit it.  A TextView is a complete text editor, however the basic class is configured to not allow editing.  TextView code in XML: <TextView android:id="@+id/simpleTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Android" />  TextView code in JAVA:  TextView textView = (TextView) findViewById(R.id.textView);  textView.setText("Android"); //set text for text view TextView
  • 51. 1 android:id This is the ID which uniquely identifies the control. 2 android:capitalize If set, specifies that this TextView has a textual input method and should automatically capitalize what the user types. •Don't automatically capitalize anything - 0 •Capitalize the first word of each sentence - 1 •Capitalize the first letter of every word - 2 •Capitalize every character - 3 3 android:cursorVisible Makes the cursor visible (the default) or invisible. Default is false. 4 android:editable If set to true, specifies that this TextView has an input method. 5 android:fontFamily Font family (named by string) for the text. 6 android:gravity Specifies how to align the text by the view's x- and/or y-axis when the text is smaller than the view. 7 android:hint Hint text to display when the text is empty. 8 android:inputType The type of data being placed in a text field. Phone, Date, Time, Number, Password etc. 13 android:password Whether the characters of the field are displayed as password dots instead of themselves. Possible value either "true" or "false".
  • 52. 14 android:phoneNumber If set, specifies that this TextView has a phone number input method. Possible value either "true" or "false". 15 android:text Text to display. 16 android:textAllCaps Present the text in ALL CAPS. Possible value either "true" or "false". 17 android:textColor Text color. May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". 21 android:textSize Size of the text. Recommended dimension type for text is "sp" for scaled-pixels (example: 15sp). 22 android:textStyle Style (bold, italic, bolditalic) for the text. You can use or more of the following values separated by '|'. •normal - 0 •bold - 1 •italic - 2 23 android:typeface Typeface (normal, sans, serif, monospace) for the text. You can use or more of the following values separated by '|'. •normal - 0 •sans - 1 •serif - 2 •monospace - 3
  • 53.  A EditText is an overlay over TextView that configures itself to be editable. It is the predefined subclass of TextView that includes rich editing capabilities.  EditText Styles of edit text
  • 54. 1 android:autoText If set, specifies that this TextView has a textual input method and automatically corrects some common spelling errors. 2 android:drawableBottom This is the drawable to be drawn below the text. 3 android:drawableRight This is the drawable to be drawn to the right of the text. 4 android:editable If set, specifies that this TextView has an input method. 5 android:text This is the Text to display. Inherited from android.widget.TextView Class
  • 55. 1 android:background This is a drawable to use as the background. 2 android:contentDescription This defines text that briefly describes content of the view. 3 android:id This supplies an identifier name for this view. 4 android:onClick This is the name of the method in this View's context to invoke when the view is clicked. 5 android:visibility:This controls the initial visibility of the view. Inherited from android.view.View Class
  • 56.  A AutoCompleteTextView is a view that is similar to EditText, except that it shows a list of completion suggestions automatically while the user is typing.  The list of suggestions is displayed in drop down menu. The user can choose an item from there to replace the content of edit box with.  The Threshold property of AutoCompleteTextView is used to define the minimum number of characters the user must type to see the list of suggestions. AutoCompleteTextView
  • 57. 1 android:completionHint This defines the hint displayed in the drop down menu. 2 android:completionThreshold This defines the number of characters that the user must type before completion suggestions are displayed in a drop down menu. 3 android:dropDownAnchor This is the View to anchor the auto-complete dropdown to. 4 android:dropDownHeight This specifies the basic height of the dropdown. 5 android:dropDownHorizontalOffset The amount of pixels by which the drop down should be offset horizontally. 6 android:dropDownSelector This is the selector in a drop down list. 7 android:dropDownVerticalOffset The amount of pixels by which the drop down should be offset vertically. 8 android:dropDownWidth This specifies the basic width of the dropdown.
  • 58.  A Button is a Push-button which can be pressed, or clicked, by the user to perform an action.  Buttons in android will contain a text or an icon or both and perform an action when the user touches it.  There are different type of buttons available to use based on the requirements, those are ImageButton, ToggleButton, RadioButton.  In html file include  android:onClick="addOperation“  In java file include  /** Called when the user touches the button */ public void addOperation(View view) { // Do something in response to the button click }  After oncreate include:  Button btnAdd = (Button)findViewById(R.id.addBtn); btnAdd.setOnClickListener(new View.OnClickListener() { public void onClick(View v) {  // Do something in response to button click } }); } Button
  • 59. 1 android:autoText If set, specifies that this TextView has a textual input method and automatically corrects some common spelling errors. 2 android:drawableBottom This is the drawable to be drawn below the text. 3 android:drawableRight This is the drawable to be drawn to the right of the text. 4 android:editable If set, specifies that this TextView has an input method. 5 android:text This is the Text to display. Inherited from android.widget.TextView Class
  • 60. 1 android:contentDescription This defines text that briefly describes content of the view. 2 android:id This supplies an identifier name for this view. 3 android:onClick This is the name of the method in this View's context to invoke when the view is clicked. 4 android:visibility This controls the initial visibility of the view. Inherited from android.view.View Class
  • 61.  Android Image Button  In android, Image Button is a user interface control that is used to display a button with an image to perform an action when the user clicks or tap on it.  Generally, the Image button in android looks similar as regular Button and perform the actions same as regular button but only difference is for image button we will add an image instead of text.  Android Toggle Button  In android, Toggle Button is a user interface control that is used to display ON (Checked) or OFF (Unchecked) states as a button with a light indicator.  Android CheckBox  In android, Checkbox is a two-states button that can be either checked or unchecked.  use check-boxes when presenting users with a group of selectable options that are not mutually exclusive.  Android Radio Button  In android, Radio Button is a two-states button that can be either checked or unchecked and it cannot be unchecked once it is checked.
  • 62.  Android Radio Group  In android, Radio Group is used to group one or more radio buttons into separate groups based on our requirements.  In case if we group radio buttons using the radio group, at a time only one item can be selected from the group of radio buttons.  Android ProgressBar  In android, ProgressBar is a user interface control which is used to indicate the progress of an operation.
  • 63. ` getMax() This method returns the maximum value of the progress. 2 incrementProgressBy(int diff) This method increments the progress bar by the difference of value passed as a parameter. 3 setIndeterminate(boolean indeterminate) This method sets the progress indicator as determinate or indeterminate. 4 setMax(int max) This method sets the maximum value of the progress dialog. 5 setProgress(int value) This method is used to update the progress dialog with some specific value.
  • 64.  Android Spinner  In android, Spinner is a drop-down list which allows a user to select one value from the list.  Android TimePicker  In android, TimePicker is a widget for selecting the time of day, either in 24-hour or AM/PM mode.  Android DatePicker  In android, DatePicker is a widget for selecting a date consisting of day, month and year