SlideShare a Scribd company logo
Android Application
Fundamentals
Android Application Fundamentals.
Android Resources
Compiled and Uncompiled Android Resources
• XML files
• Raw files
String Resources
• Define strings in one or more
XML resource files.
• These XML files containing
string-resource definitions
reside in the /res/values
subdirectory.
strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">hello</string>
<string name="app_name">hello
appname</string>
</resources>
Android Resources
Layout Resources
• A key resource used in
Android UI programming.
public class HelloWorldActivity extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
...
}
Android Resources
Example main.xml Layout File
<?xml version="1.0" encoding="utf-
8"?>
<LinearLayout
xmlns:android="http://schemas.andr
oid.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</LinearLayout>
Android Resources
Color Resources
<resources>
<color name="red">#f00</color>
<color
name="blue">#0000ff</color>
<color
name="green">#f0f0</color>
<color
name="main_back_ground_color">
#ffffff00</color>
</resources>
Android Resources
Color Resources in Java code
int mainBackGroundColor =
activity.getResources.getColor(R.color.main_back_ground_color);
Using Colors in View Definitions
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/red"
android:text="Sample Text to Show Red Color"/>
Android Resources
Dimension Resources
You can specify the dimensions in any of the following units:
px: Pixels
in: Inches
mm: Millimeters
pt: Points
dp: Density-independent pixels based on pixel density per inch
sp: Scale-independent pixels (dimensions that allow for user sizing;
helpful for use in fonts)
Android Resources
XML Syntax for Defining Dimension
Resources
<resources>
<dimen name="mysize_in_pixels">1px</dimen>
<dimen name="mysize_in_dp">5dp</dimen>
<dimen name="medium_size">100sp</dimen>
</resources>
Using Dimension Resources in XML
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/medium_size"/>
Android Resources
Image Resources
Using Image Resources in XML
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Dial"
android:background="@drawable/sample_image"
/>
Android Resources
Android Resources
package com.mycompany.android.my-root-package;
public final class R {
...other entries depending on your project and application
public static final class string
{
...other entries depending on your project and application
publicstaticfinal int hello=0x7f040000;
publicstaticfinal int app_name=0x7f040001;
...other entries depending on your project and application
}
...other entries depending on your project and application
}
• R.java with unique IDs for the
two string resources specified.
R.java
Resource Reference Syntax
Android resources are identified (or referenced) by their IDs in Java source code.
<TextView android:id="@+id/text">
//Success: Creates an id called "text" in the local package's R.java
In the syntax "@+id/text", the + sign has a special meaning. It tells Android that the ID
text may not already exist
Android Resources
Android
View and ViewGroup
Buttons
Basic Button
<Button android:id="@+id/button1"
android:text="@string/basicBtnLabel"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
……………………
ImageButton
<ImageButton android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="myClickHandler"
android:src="@drawable/icon" />
……………..
ImageButton imageButton2 =
(ImageButton)this.findViewById(R.id.imageButton2);
imageButton2.setImageResource(R.drawable.icon);
Buttons
ToggleButton
<ToggleButton android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Toggle Button"
android:textOn="Stop"
android:textOff="Run"/>
Button button1 = (Button)this.findViewById(R.id.button1);
button1.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.androidbook.com"));
startActivity(intent);
}
});
Buttons
CheckBox
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<CheckBox android:id="@+id/chickenCB"
android:text="Chicken" android:checked="true"
android:layout_width=“wrap_content"
android:layout_height="wrap_content" />
<CheckBox android:id="@+id/fishCB" android:text="Fish"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<CheckBox android:id="@+id/steakCB"
android:text="Steak" android:checked="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
CheckBox
RadioButton
RadioButton
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RadioGroup android:id="@+id/rBtnGrp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RadioButton android:id="@+id/chRBtn"
android:text="Chicken"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
………………………..
</RadioGroup>
</LinearLayout>
RadioButton
ImageView
<ImageView android:id="@+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content“
android:src="@drawable/abc"
/>
DatePicker
<DatePicker android:id="@+id/datePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
………………………..
DatePicker dp = (DatePicker)this.findViewById(R.id.datePicker);
dateDefault.setText("Date defaulted to " + (dp.getMonth() + 1) + "/" +
dp.getDayOfMonth() + "/" + dp.getYear());
dp.init(2008, 11, 10, null);
TimePicker
<TimePicker android:id="@+id/timePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
………………………..
TimePicker tp = (TimePicker)this.findViewById(R.id.timePicker);
tp.setIs24HourView(true);
tp.setCurrentHour(new Integer(10));
tp.setCurrentMinute(new Integer(10));
Pickers
DigitalClock
<DigitalClock
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
AnalogClock
<AnalogClock
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Pickers
ListView
<ListView android:id="@+id/list"
android:layout_width=" wrap_content "
android:layout_height=" wrap_content "
android:entries=“@array/mylist” />
List
Layout Manager
Layout Manager Description
LinearLayout Organizes its children either horizontally or vertically
TableLayout Organizes its children in tabular form
RelativeLayout Organizes its children relative to one another or to
the parent
FrameLayout Allows you to dynamically changethe control(s) in
the layout
Layout Manager
LinearLayout
<LinearLayout
xmlns:android="http://schemas.android.com/a
pk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!—add components-->
</LinearLayout>
Layout Manager
RelativeLayout
<RelativeLayout …………… >
<TextView android:id="@+id/userNameLbl"
android:text="Username: “
android:layout_alignParentTop="true" />
<EditText android:id="@+id/userNameText"
android:layout_toRightOf="@id/userNameLbl" />
<TextView android:id="@+id/pwdLbl"
android:layout_below="@id/userNameText"
android:text="Password: " />
<EditText android:id="@+id/pwdText"
android:layout_toRightOf="@id/pwdLbl"
android:layout_below="@id/userNameText" />
<TextView android:id="@+id/pwdCriteria"
android:layout_below="@id/pwdText"
android:text="Password Criteria... " />
</RelativeLayout>
TableLayout
<TableLayout ……… >
<TableRow>
<TextView android:text="First Name:“
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText android:text="Edgar“
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow>
<TextView android:text="Last Name:"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText android:text="Poe"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
</TableLayout>
Layout Manager
Layout Manager
FrameLayout
<FrameLayout android:id="@+id/frmLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/oneImgView"
android:src="@drawable/one"
android:scaleType="fitCenter"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<ImageView
android:id="@+id/twoImgView"
android:src="@drawable/two"
android:scaleType="fitCenter"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="gone" />
</FrameLayout>
Styles
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name=“SpelError">
<item
name="android:layout_width">fill_parent</item>
<item
name="android:layout_height">wrap_content</item>
<item name="android:textColor">#FF0000</item>
<item
name="android:typeface">monospace</item>
</style>
</resources>
………………..
<TextView android:id="@+id/errorText"
style="@style/ SpelError"
android:text=“Styling”
/>
Styles
Themes
If you have some style elements you want applied across an entire activity, or across
the whole application, you should use a theme instead. A theme is it’s exactly like a
style. To specify a theme for an activity or an application, we would add an attribute
to the <activity>or <application>tag in the AndroidManifest.xml.
<activity android:theme="@style/MyActivityTheme">
<application android:theme="@style/MyApplicationTheme">
Themes
Android Application Fundamentals.

More Related Content

Similar to Android Application Fundamentals. (20)

PPTX
Android Development for Beginners with Sample Project - Day 1
Joemarie Amparo
 
PPTX
Android Development Made Easy - With Sample Project
Joemarie Amparo
 
PPT
Synapseindia android apps introduction hello world
Tarunsingh198
 
DOCX
Android resources in android-chapter9
Dr. Ramkumar Lakshminarayanan
 
ODP
Android App Development - 03 Resources
Diego Grancini
 
DOCX
Android Resources.docx
KNANTHINIMCA
 
PDF
Android App Development 08 : Support Multiple Devices
Anuchit Chalothorn
 
KEY
Android momobxl
Steven Palmaers
 
PDF
Android resource
Krazy Koder
 
PPTX
Building a simple user interface lesson2
Kalluri Vinay Reddy
 
PDF
Quick Intro to Android Development
Jussi Pohjolainen
 
PDF
Android Application Development - Level 1
Isham Rashik
 
PPTX
Android Tutorials : Basic widgets
Prajyot Mainkar
 
ODP
Android introduction
PingLun Liao
 
PPT
eyeryeryeryeryeyeyeryeryyerye13872085.ppt
FarhanGhafoor7
 
PPTX
Android Studio development model and.pptx
VaibhavKhunger2
 
PDF
Basics and different xml files used in android
Mahmudul Hasan
 
PPT
Android Bootcamp Tanzania:understanding ui in_android
Denis Minja
 
PDF
Introduction to Andriod Studio Lecture note: Android Development Lecture 1.pdf
AliyuIshaq2
 
PPTX
06. Android Basic Widget and Container
Oum Saokosal
 
Android Development for Beginners with Sample Project - Day 1
Joemarie Amparo
 
Android Development Made Easy - With Sample Project
Joemarie Amparo
 
Synapseindia android apps introduction hello world
Tarunsingh198
 
Android resources in android-chapter9
Dr. Ramkumar Lakshminarayanan
 
Android App Development - 03 Resources
Diego Grancini
 
Android Resources.docx
KNANTHINIMCA
 
Android App Development 08 : Support Multiple Devices
Anuchit Chalothorn
 
Android momobxl
Steven Palmaers
 
Android resource
Krazy Koder
 
Building a simple user interface lesson2
Kalluri Vinay Reddy
 
Quick Intro to Android Development
Jussi Pohjolainen
 
Android Application Development - Level 1
Isham Rashik
 
Android Tutorials : Basic widgets
Prajyot Mainkar
 
Android introduction
PingLun Liao
 
eyeryeryeryeryeyeyeryeryyerye13872085.ppt
FarhanGhafoor7
 
Android Studio development model and.pptx
VaibhavKhunger2
 
Basics and different xml files used in android
Mahmudul Hasan
 
Android Bootcamp Tanzania:understanding ui in_android
Denis Minja
 
Introduction to Andriod Studio Lecture note: Android Development Lecture 1.pdf
AliyuIshaq2
 
06. Android Basic Widget and Container
Oum Saokosal
 

More from Skillwise Consulting (19)

PDF
Insurace brochure for clients
Skillwise Consulting
 
PDF
Health care profile
Skillwise Consulting
 
PDF
Manufacturing profile
Skillwise Consulting
 
PDF
Skillwise profile
Skillwise Consulting
 
PPTX
Technology platform
Skillwise Consulting
 
PPTX
JMETER-SKILLWISE
Skillwise Consulting
 
PPTX
SKILLWISE_SELENIUM
Skillwise Consulting
 
PPTX
SKILLWISE-BIGDATA ANALYSIS
Skillwise Consulting
 
PPTX
Skillwise Consulting_Android
Skillwise Consulting
 
PPTX
Technical Comptency_ppt
Skillwise Consulting
 
PPTX
Advanced Soft skill_Skillwise Consulting
Skillwise Consulting
 
PPTX
Technical Skillwise
Skillwise Consulting
 
PPTX
Softskill skillwise consulting ppt
Skillwise Consulting
 
PPTX
Skillwise Consulting_Soft skills
Skillwise Consulting
 
PDF
Skillwise_Technical competency
Skillwise Consulting
 
PPTX
Skillwise consulting _Soft Skills
Skillwise Consulting
 
PPTX
Skillwise Consulting -Technical competency
Skillwise Consulting
 
PDF
Skillwise Profile
Skillwise Consulting
 
PDF
Skillwise Consulting
Skillwise Consulting
 
Insurace brochure for clients
Skillwise Consulting
 
Health care profile
Skillwise Consulting
 
Manufacturing profile
Skillwise Consulting
 
Skillwise profile
Skillwise Consulting
 
Technology platform
Skillwise Consulting
 
JMETER-SKILLWISE
Skillwise Consulting
 
SKILLWISE_SELENIUM
Skillwise Consulting
 
SKILLWISE-BIGDATA ANALYSIS
Skillwise Consulting
 
Skillwise Consulting_Android
Skillwise Consulting
 
Technical Comptency_ppt
Skillwise Consulting
 
Advanced Soft skill_Skillwise Consulting
Skillwise Consulting
 
Technical Skillwise
Skillwise Consulting
 
Softskill skillwise consulting ppt
Skillwise Consulting
 
Skillwise Consulting_Soft skills
Skillwise Consulting
 
Skillwise_Technical competency
Skillwise Consulting
 
Skillwise consulting _Soft Skills
Skillwise Consulting
 
Skillwise Consulting -Technical competency
Skillwise Consulting
 
Skillwise Profile
Skillwise Consulting
 
Skillwise Consulting
Skillwise Consulting
 
Ad

Recently uploaded (20)

PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Ad

Android Application Fundamentals.