Upload
daniel-midrees
View
219
Download
0
Embed Size (px)
Citation preview
28th May 2015, NED University
ANDROID DEVELOPMENT WORKSHOP
Daniel Muhammad Idrees
• Software Engineer - Interactive Health Solutions (www.ihsinformatics.com) (Dec 2013 – Present)
• Lead Android Trainer – SkillOrbit(www.skillorbit.com) (May 2015 – Present)
• Private Tutor and Trainer (Dec 2014 – Present)
• Internee - Open Integrated Solutions (May 2012 – Sept
2012)
• Computer & Information Systems Engineer (NED University, Batch 2009-10)
• O Levels Teacher (2009 – May 2015)Email: [email protected] LinkedIn: www.linkedin.com/in/danielmidreesFacebook: www.facebook.com/daniel.mi
What to Expect?
• Guidance• Counseling• Mentorship
What not to Expect?
Spoon Feeding!
Variables• Data Types
o Primitive Typeso Non-primitive Types
• Local Variableso Choosing Data Typeo Declaring (String string;)o Initializing (string = “Hello”)
• Access Modifiers• Class (static) Variables• Instance (non-static) Variables
Primitive Data Types
Non-Primitive Data Types• User-created• Nullable• Also called “Reference Types”• Examples:
o Arrayso Stringo Lists
Access Modifiers• Access Modifiers
o Publico Privateo Protectedo Default
Operators
• Airthematic (+, -, *, /, ++, --, %)• Relational (==, >=, <=, !=, >, <)• Logical (&& , | |, !)
Controlling Flow of Execution
• Conditionso if – elseo switch
• Loopso foro while
• Special Control Statementso break, continueo Returno try-catch-finally
Function• Signatures• Naming• Parameters• Returning Values• Static/Non-static Functions• Calling Functions
Arrays• Arrays
o Collection of Similar Items in Sequenceo Contains values or referenceso Fixed, Finite Length
• Length• Index• Initialization• Enhanced for loop
Best Coding Practices
• Indentation
• Naming Convention• Use of Comments
Be an Engineer!Not a Mechanic!
Object Oriented Programming• Objects and Classes
o Object: Instance of a Classo Class: Blueprint of an Object
Pillars of OOP• Inheritance
• Polymorphismo Method Overloadingo Method Overriding
Pillars of OOP• Abstraction
o Biggest Challenge in OOPo Relevant Attributes and Behavioro Abstract and Concrete Classes
• Encapsulationo Hiding Datao Hiding Implementationo Access/Mutate (simply, get/set)
Interfaces• Why Not Multiple Inheritance?• Interfaces are Pure Abstract Classes• Rules
o No Instanceso No Constructorso Only Method Signatureso Only static final Members
Read more JAVA from:
• Java Actually by Khalid A. Mughal• The Complete Reference Java by Herbert Schildt• http://www.tutorialspoint.com/java/• http://www.javatpoint.com/java-tutorial
Take Help From:• Stackoverflow• Google!
Introduction to Android
Development
Manifest File<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.package.default" android:versionCode="1" android:versionName="1.0" >
<uses-sdk android:minSdkVersion="11" android:targetSdkVersion="21" />
<application> <activity android:name="com.resume.daniyalmuhammadidrees.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application></manifest>
Strings.xml
<rescource
<string name="app_name">The name of your App!</string>
</resource>
@String/app_name “The name of your App!”
Layout.xml• Types of Layouts
o LinearLayouto RelativeLayouto TableLayouto GridLayouto FrameLayouto Fragment
• Views (Buttons, TextView, EditText etc)• ViewGroup (Invisible container, contains Views)
Width and Height of Views
android:layout_width="match_parent"android:layout_height="match_parent“
android:layout_width=“fill_parent"android:layout_height=“fill_parent“
android:layout_width=“wrap_content"android:layout_height=“wrap_content“
• wrap_content ( Take only as much as you need)• match_parent (Take everything you can )• fill_parent (Take as much as your parent have)
Accessing views through code
Activity Lifecycle• Activity• Lifecycle Methods
Orientation• Landscape and Portrait• Changing Orientation of Device• Emulator shortcut key ‘Left Ctrl + F11’• Setting fix Orientation of an Activity
More on UI• Padding
• Margin
• Gravity
• Weightsum
Weightsum = 3
Layout_weight (View)= 1
Linear Layout• Arrange views in a line vertically or horizontally. • Views can have Layout Weight and Layout
Gravity.
Relative Layout• Place views with respect to other view or Parent• Views inside RL does not have Layout Weight and
Layout Gravity.
Table Layout• Arrange views in rows and columns.• TableRow is MATCH_PARENT in width and
WRAP_CONTENT in height• <TableRows> (Views) </TableRows>• Columns in a row will be equal to number of
views in that row.
Grid Layout• Arrange views in rows and columns.• Available in API Level 14 and higher.• Set Row Count and Column Count.
Frame Layout• Views are stacked on top of each other.
ScrollView• ScrollView• HorizontalScrollView
• Events• Listener• Example of Button Click
Concept of Listener
Custom Button• Design an Image of a Button.
• Design an Image of a pressed Button.
• Create an xml file in drawable folder.
• Call that xml in your layout View.
http://angrytools.com/android/button/http://www.dibbus.com/2011/02/gradient-buttons-for-android/
Click
Click
Building Blocks of Android
• ActivitiesSomething which user interacts with.
• ServicesSomething that runs in the background.
• Broadcast ReceiversRespond to broadcast messages by
applications or the system itself.• Intents
Messenger carrying message.
• Used to start a new Activity• Used to start a Service• Used to get notifications from Broadcast
Receivers • <Intent-filter>• Explicit Intents (there is a target)• Implicit Intents (there is no SPECIFIC target)
Intents
Thank You!