1. This work is licensed under the Apache 2.0 License
Prior Programming Experience Track: Session 2
Android Study Jams
Android Facilitator: Ritika Talukdar
2. This work is licensed under the Apache 2.0 License
TOPIC TIME
Kotlin Koans revision 6:00-6:45
Pathway 1 and 2 6:45-7:05
Pathway 3 7:05 - 7:30Today’s Schedule
3. This work is licensed under the Apache 2.0 License
4. This work is licensed under the Apache 2.0 License
5. This work is licensed under the Apache 2.0 License
Arrays
val num = arrayOf(1, 2, 3, 4) //implicit type declaration
val num = arrayOf<Int>(1, 2, 3) //explicit type declaration
6. This work is licensed under the Apache 2.0 License
Strings
● Strings:
var s = “Welcome to Android Study Jams” //implicit type declaration
var s: String = “Welcome to Android Study Jams” //explicit type declaration
7. This work is licensed under the Apache 2.0 License
Loops
● While loop:
while (condition) {
statement
Iteration
}
Eg. while(i<=10){
println(i)
i++
}
● Do While Loop:
do {
statement
Iteration
} while(condition)
Eg. do{
println(i)
i++
}while(i<=10)
8. This work is licensed under the Apache 2.0 License
● For Loop:
for (iterations){
operations to perform
}
Eg. for( i in 0..10){
println(i)
}
OUTPUT:
0
1
2
3
4
5
6
7
8
9
10
9. This work is licensed under the Apache 2.0 License
Lambda expressions are 'function literals', i.e. functions that are not declared, but passed
immediately as an expression. Consider the following example:
max(strings, { a, b -> a.length < b.length })
Function max is a higher-order function, it takes a function value as the second argument.
This second argument is an expression that is itself a function, i.e. a function literal, which is
equivalent to the following named function:
fun compare(a: String, b: String): Boolean = a.length < b.length
Lambda Expressions
10. This work is licensed under the Apache 2.0 License
It's very common that a lambda expression has only one parameter.
The parameter will be implicitly declared under the name it:
abc.filter { it > 0 } // this literal is of type '(it: Int) -> Boolean'
“It”: Implicit name of a single parameter
11. This work is licensed under the Apache 2.0 License
Data Classes
12. This work is licensed under the Apache 2.0 License
Concept Overview
13. This work is licensed under the Apache 2.0 License
Android Studio
14. This work is licensed under the Apache 2.0 License
Android Emulator
15. This work is licensed under the Apache 2.0 License
Aa
Button
Layout
s
Views
Layouts
Pathway 1 Pathway 2 Pathway 3
16. This work is licensed under the Apache 2.0 License
TextView ImageView Button
Hello Android!
Views
17. This work is licensed under the Apache 2.0 License
FrameLayout
TextView
TextView
TextView
Button
LinearLayout
TextView
Button
ConstraintLayout
TextView
ViewGroups
18. Used to align all views in a
single direction- either
horizontally or vertically.
The views will be stacked
one after the other
irrespective of their width.
Linear Layout
19. Used to arrange views in
positions relative to the
Parent layout.
Used when we want to
arrange the widgets in
relation to one another’s
positions.
Relative Layout
20. This work is licensed under the Apache 2.0 License
Hello World!
Declare layouts in XML
<TextView
android:text="Hello World!"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
21. This work is licensed under the Apache 2.0 License
● Activity
● Resources (layout files, images, strings, themes, etc...)
● AndroidManifest.xml
● Gradle files
Anatomy of a Basic App Project
22. This work is licensed under the Apache 2.0 License
Logistics
Android Kotlin Fundamentals
course
23. This work is licensed under the Apache 2.0 License
Go to
g.co/android/studyjams
Prior Programming
Experience track
24. This work is licensed under the Apache 2.0 License
Android Fundamentals
Course
Click Start Course
25. This work is licensed under the Apache 2.0 License
Android Kotlin
Fundamentals Course
26. This work is licensed under the Apache 2.0 License
Unit 1
27. This work is licensed under the Apache 2.0 License
A Pathway
28. This work is licensed under the Apache 2.0 License
Badges
29. This work is
licensed under
the Apache 2.0
License
Apps You’ll Build
Dice Roller App About Me App ColorMyViews
App
30. This work is licensed under the Apache 2.0 License
Share what you’ve
learnt with
#AndroidStudyJams, #dsc #igdtuw and
#DeveloperStudentClubs and tag
@googledevs, @GoogleStudents and
@DSCIGDTUW