SlideShare a Scribd company logo
1 of 22
Stargazing at State
Migration Meadow
Testing Trails
Performance Peak
Layout Lake
Material Tents
Google Developer Student Clubs
Bakhtiyarpur College Of Engineering - Patna
This work is licensed under the Apache 2.0 License
Compose Camp #2
Introduction to Kotlin,
Adding a Button &
Interaction with UI
Google Developer Student Clubs
Bakhtiyarpur College Of Engineering - Patna
22nd September, 2022
This work is licensed under the Apache 2.0 License
Agenda
Introduction to Kotlin
● What is Kotlin ?
● History of Kotlin
● Why Kotlin ?
● main() function
● Variables in Kotlin
● Control Flow
● if…else
● when
● Loops
○ for
○ while
○ do while
● functions
Adding a button
● Creating our first application
using Android Studio
● Understanding the basic layout of
Android Studio
● Writing codes using Kotlin
● Run them on Emulator
Interacting with UI & state
● Adding functionality to button
● Run code live
This work is licensed under the Apache 2.0 License
What is Kotlin ?
Kotlin is a general purpose, free, open source, modern programming
language which also supports cross-platform. It supports OOP and is
better than JAVA for android app development. For iOS some
framework like Codename One or Kotlin Multi platform is used.
It was introduced by JetBrains in 2011.
At Google I/0 2017, Google announced first-class support for Kotlin on
Android and announced Kotlin as an official language for android
development.
Kotlin Fundamentals
This work is licensed under the Apache 2.0 License
Why Kotlin ?
Kotlin is designed to interoperate fully with Java,
and the JVM version of kotlin's standard library
depends on the Java class library
Google made Kotlin as first preference for developing
apps
30% less code as compared to Java
Time spent on reviews and maintenance is less
60% professional Android developers use Kotlin
This work is licensed under the Apache 2.0 License
Kotlin is an programming language that
combines object-oriented
programming and functional features
into a unique platform.
main() function - Entry point of the kotlin application
function declaration –> fun keyword
Example :
fun main(args:Array<string>)
{
println(“Welcome to Compose Camp ”)
}
main() FUNCTION :-
This work is licensed under the Apache 2.0 License
VARIABLES :-
Variables in kotlin :-
A simple Box in which we can hold the data.
There are mainly two types of variables in Kotlin:
1. var 2. val
var and val :-
● var can be reassigned.
● val can’t be reassigned.
This work is licensed under the Apache 2.0 License
Data Types in Kotlin :-
There are mainly Four types of data
types:
1. Integer 2. Floating Point
3. Boolean 4. Character
fun main () {
var score :Int= 12
var température:Double=89.4
var isRaining:Boolean = false
var alphabet: char=’A’
var message: string=”Hello World”
}
This work is licensed under the Apache 2.0 License
Control Flow :-
if-else :-
if (condition) {
// Run this code if condition is true
}
else {
// Run this code if condition is false
}
This work is licensed under the Apache 2.0 License
Control Flow :-
When :-
It is similar to switch case which is used in C/C++.
Readability of code is more than if-else statement.
fun main ( ) {
val animal =”horse”
// if (animal ==”Horse”) {
//println(“Animal is Horse”)
// }
//else if (animal==”Cat”) {
// println(“Animal is Cat”) } }
when(animal) {
“horse”->println(“Animal is
Horse”)
“Cat”->println(“Animal is Cat”)
else -> println(“Animal not found”)
}
}
This work is licensed under the Apache 2.0 License
for Loop
a for-loop is a control flow statement for specific iteration , which allows code
to be executed repeatedly.
LOOPS:
fun main ( )
{
for(item in 1…5)
{
println(item)
}
}
This work is licensed under the Apache 2.0 License
The while loop through a block of code as long a specified condition is true .
while Loop:-
fun main ( )
{
while (condition)
{
// code block to be executed while
// the condition is true
}
}
This work is licensed under the Apache 2.0 License
The do…while is similar to the loop with a difference that the this loop will executed to
the code block once, before checking if the condition is true , then it will repeat the loop
as long as the condition is true.
do…while Loop:-
fun main ( )
{
do {
// Body of the loop
}
while (condition)
}
This work is licensed under the Apache 2.0 License
FUNCTIONS :-
Block of code to perform certain functionality and helps to reuse the code
Syntax of function
:-
fun functionName(par1,par2,....: ReturnType)
{
Block of statements
return result
}
Example :
This work is licensed under the Apache 2.0 License
Let’s build this on Android Studio
Add a button to App
Add a button to App
This work is licensed under the Apache 2.0 License
Let’s build this on Android Studio
Interacting with UI & state
Interacting with UI &States
This work is licensed under the Apache 2.0 License
Earn digital badges
For each quiz successfully
passed
This work is licensed under the Apache 2.0 License
Carrie Sawyer
See Developer Profile FAQ
Badges are added
to your
Google Developer Profile
This work is licensed under the Apache 2.0 License
Milestones
Attend sessions and
workshops organised
by GDSC BCE Patna
Complete all the
units under
different tracks
Build apps with
Compose with the
guidelines provided
(app development
guidelines coming soon)*
This work is licensed under the Apache 2.0 License
App submission
Coming Soon !!
This work is licensed under the Apache 2.0 License
Compose Camp Week #2 Content
Kotlin Fundamentals Add a button to App Interacting with UI &States
This work is licensed under the Apache 2.0 License
THANK
YOU
Google Developer Student Clubs
Bakhtiyarpur College Of Engineering - Patna

More Related Content

Similar to Compose camp 2.pptx

Compose Camp Slide Session 1
Compose Camp Slide Session 1Compose Camp Slide Session 1
Compose Camp Slide Session 1AkshatBajpai12
 
-Kotlin_Camp_Unit2.pptx
-Kotlin_Camp_Unit2.pptx-Kotlin_Camp_Unit2.pptx
-Kotlin_Camp_Unit2.pptxRishiGandhi19
 
Session 1 ppt.pptx
Session 1 ppt.pptxSession 1 ppt.pptx
Session 1 ppt.pptxSumit766160
 
Compose_camp_Day_1.pptx
Compose_camp_Day_1.pptxCompose_camp_Day_1.pptx
Compose_camp_Day_1.pptxGanpatParmar1
 
Android Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdf
Android Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdfAndroid Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdf
Android Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdfShivamShrey1
 
Compose Camp Day 1.pdf
Compose Camp Day 1.pdfCompose Camp Day 1.pdf
Compose Camp Day 1.pdfShivamShrey1
 
Kotlin Basics & Introduction to Jetpack Compose.pptx
Kotlin Basics & Introduction to Jetpack Compose.pptxKotlin Basics & Introduction to Jetpack Compose.pptx
Kotlin Basics & Introduction to Jetpack Compose.pptxtakshilkunadia
 
Compose Camp: Introduction to Kotlin.pptx
Compose Camp: Introduction to Kotlin.pptxCompose Camp: Introduction to Kotlin.pptx
Compose Camp: Introduction to Kotlin.pptxAmruthasriAmaravati
 
Android Study Jam 1 Day 1 | December 2021 | GDSC BVCOENM
Android Study Jam 1 Day 1 | December 2021 | GDSC BVCOENMAndroid Study Jam 1 Day 1 | December 2021 | GDSC BVCOENM
Android Study Jam 1 Day 1 | December 2021 | GDSC BVCOENMGDSCBVCOENM
 
Introduction to KOTLIN.pptx
Introduction to KOTLIN.pptxIntroduction to KOTLIN.pptx
Introduction to KOTLIN.pptxAkankshaPathak42
 
Prior programming experience track
Prior programming experience trackPrior programming experience track
Prior programming experience trackAshwinRaj57
 
Android study jams
Android study jamsAndroid study jams
Android study jamsNaveenK158
 
Android study jam iiitv kick-off sesson
Android study jam iiitv   kick-off sessonAndroid study jam iiitv   kick-off sesson
Android study jam iiitv kick-off sessonAshutoshSingh1124
 
Google Solution Challenge Android Awesomeness.pptx
Google Solution Challenge Android Awesomeness.pptxGoogle Solution Challenge Android Awesomeness.pptx
Google Solution Challenge Android Awesomeness.pptxGoogleDeveloperStude22
 

Similar to Compose camp 2.pptx (20)

Compose Camp.pdf
Compose Camp.pdfCompose Camp.pdf
Compose Camp.pdf
 
Compose Camp - Session1.pdf
Compose Camp - Session1.pdfCompose Camp - Session1.pdf
Compose Camp - Session1.pdf
 
Compose Camp Slide Session 1
Compose Camp Slide Session 1Compose Camp Slide Session 1
Compose Camp Slide Session 1
 
Compose Camp Session 1.pdf
Compose Camp Session 1.pdfCompose Camp Session 1.pdf
Compose Camp Session 1.pdf
 
-Kotlin_Camp_Unit2.pptx
-Kotlin_Camp_Unit2.pptx-Kotlin_Camp_Unit2.pptx
-Kotlin_Camp_Unit2.pptx
 
-Kotlin Camp Unit2.pptx
-Kotlin Camp Unit2.pptx-Kotlin Camp Unit2.pptx
-Kotlin Camp Unit2.pptx
 
Session 1 ppt.pptx
Session 1 ppt.pptxSession 1 ppt.pptx
Session 1 ppt.pptx
 
Compose_camp_Day_1.pptx
Compose_camp_Day_1.pptxCompose_camp_Day_1.pptx
Compose_camp_Day_1.pptx
 
Android Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdf
Android Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdfAndroid Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdf
Android Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdf
 
Compose Camp Day 1.pdf
Compose Camp Day 1.pdfCompose Camp Day 1.pdf
Compose Camp Day 1.pdf
 
Kotlin Basics & Introduction to Jetpack Compose.pptx
Kotlin Basics & Introduction to Jetpack Compose.pptxKotlin Basics & Introduction to Jetpack Compose.pptx
Kotlin Basics & Introduction to Jetpack Compose.pptx
 
Compose Camp: Introduction to Kotlin.pptx
Compose Camp: Introduction to Kotlin.pptxCompose Camp: Introduction to Kotlin.pptx
Compose Camp: Introduction to Kotlin.pptx
 
Android Study Jam 1 Day 1 | December 2021 | GDSC BVCOENM
Android Study Jam 1 Day 1 | December 2021 | GDSC BVCOENMAndroid Study Jam 1 Day 1 | December 2021 | GDSC BVCOENM
Android Study Jam 1 Day 1 | December 2021 | GDSC BVCOENM
 
Introduction to KOTLIN.pptx
Introduction to KOTLIN.pptxIntroduction to KOTLIN.pptx
Introduction to KOTLIN.pptx
 
Prior programming experience track
Prior programming experience trackPrior programming experience track
Prior programming experience track
 
Compose Camp.pptx
Compose Camp.pptxCompose Camp.pptx
Compose Camp.pptx
 
Android study jams
Android study jamsAndroid study jams
Android study jams
 
Android study jam iiitv kick-off sesson
Android study jam iiitv   kick-off sessonAndroid study jam iiitv   kick-off sesson
Android study jam iiitv kick-off sesson
 
Compose #1.pptx
Compose #1.pptxCompose #1.pptx
Compose #1.pptx
 
Google Solution Challenge Android Awesomeness.pptx
Google Solution Challenge Android Awesomeness.pptxGoogle Solution Challenge Android Awesomeness.pptx
Google Solution Challenge Android Awesomeness.pptx
 

More from bcedsc

INDUCTION 2023.pdf
INDUCTION 2023.pdfINDUCTION 2023.pdf
INDUCTION 2023.pdfbcedsc
 
Machine Learning
Machine LearningMachine Learning
Machine Learningbcedsc
 
Introduction To Flutter
Introduction To FlutterIntroduction To Flutter
Introduction To Flutterbcedsc
 
Let's Flutter
Let's FlutterLet's Flutter
Let's Flutterbcedsc
 
JAVASCRIPT UNLEASHED
JAVASCRIPT UNLEASHEDJAVASCRIPT UNLEASHED
JAVASCRIPT UNLEASHEDbcedsc
 
Getting Started with HTML & CSS
Getting Started with HTML & CSSGetting Started with HTML & CSS
Getting Started with HTML & CSSbcedsc
 
Solution Challenge_ Info Session.pptx
Solution Challenge_ Info Session.pptxSolution Challenge_ Info Session.pptx
Solution Challenge_ Info Session.pptxbcedsc
 
web roadmap.pdf
web roadmap.pdfweb roadmap.pdf
web roadmap.pdfbcedsc
 
GCCP '22 Introduction & Instructions
GCCP '22 Introduction & InstructionsGCCP '22 Introduction & Instructions
GCCP '22 Introduction & Instructionsbcedsc
 
Hacktoberfest.pdf
Hacktoberfest.pdfHacktoberfest.pdf
Hacktoberfest.pdfbcedsc
 
Compose camp 4.pptx
Compose camp 4.pptxCompose camp 4.pptx
Compose camp 4.pptxbcedsc
 
compose camp 1.pptx
compose camp 1.pptxcompose camp 1.pptx
compose camp 1.pptxbcedsc
 
GDSC Induction 2022.pdf
GDSC Induction 2022.pdfGDSC Induction 2022.pdf
GDSC Induction 2022.pdfbcedsc
 

More from bcedsc (13)

INDUCTION 2023.pdf
INDUCTION 2023.pdfINDUCTION 2023.pdf
INDUCTION 2023.pdf
 
Machine Learning
Machine LearningMachine Learning
Machine Learning
 
Introduction To Flutter
Introduction To FlutterIntroduction To Flutter
Introduction To Flutter
 
Let's Flutter
Let's FlutterLet's Flutter
Let's Flutter
 
JAVASCRIPT UNLEASHED
JAVASCRIPT UNLEASHEDJAVASCRIPT UNLEASHED
JAVASCRIPT UNLEASHED
 
Getting Started with HTML & CSS
Getting Started with HTML & CSSGetting Started with HTML & CSS
Getting Started with HTML & CSS
 
Solution Challenge_ Info Session.pptx
Solution Challenge_ Info Session.pptxSolution Challenge_ Info Session.pptx
Solution Challenge_ Info Session.pptx
 
web roadmap.pdf
web roadmap.pdfweb roadmap.pdf
web roadmap.pdf
 
GCCP '22 Introduction & Instructions
GCCP '22 Introduction & InstructionsGCCP '22 Introduction & Instructions
GCCP '22 Introduction & Instructions
 
Hacktoberfest.pdf
Hacktoberfest.pdfHacktoberfest.pdf
Hacktoberfest.pdf
 
Compose camp 4.pptx
Compose camp 4.pptxCompose camp 4.pptx
Compose camp 4.pptx
 
compose camp 1.pptx
compose camp 1.pptxcompose camp 1.pptx
compose camp 1.pptx
 
GDSC Induction 2022.pdf
GDSC Induction 2022.pdfGDSC Induction 2022.pdf
GDSC Induction 2022.pdf
 

Recently uploaded

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
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
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 

Recently uploaded (20)

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
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
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 

Compose camp 2.pptx

  • 1. Stargazing at State Migration Meadow Testing Trails Performance Peak Layout Lake Material Tents Google Developer Student Clubs Bakhtiyarpur College Of Engineering - Patna
  • 2. This work is licensed under the Apache 2.0 License Compose Camp #2 Introduction to Kotlin, Adding a Button & Interaction with UI Google Developer Student Clubs Bakhtiyarpur College Of Engineering - Patna 22nd September, 2022
  • 3. This work is licensed under the Apache 2.0 License Agenda Introduction to Kotlin ● What is Kotlin ? ● History of Kotlin ● Why Kotlin ? ● main() function ● Variables in Kotlin ● Control Flow ● if…else ● when ● Loops ○ for ○ while ○ do while ● functions Adding a button ● Creating our first application using Android Studio ● Understanding the basic layout of Android Studio ● Writing codes using Kotlin ● Run them on Emulator Interacting with UI & state ● Adding functionality to button ● Run code live
  • 4. This work is licensed under the Apache 2.0 License What is Kotlin ? Kotlin is a general purpose, free, open source, modern programming language which also supports cross-platform. It supports OOP and is better than JAVA for android app development. For iOS some framework like Codename One or Kotlin Multi platform is used. It was introduced by JetBrains in 2011. At Google I/0 2017, Google announced first-class support for Kotlin on Android and announced Kotlin as an official language for android development. Kotlin Fundamentals
  • 5. This work is licensed under the Apache 2.0 License Why Kotlin ? Kotlin is designed to interoperate fully with Java, and the JVM version of kotlin's standard library depends on the Java class library Google made Kotlin as first preference for developing apps 30% less code as compared to Java Time spent on reviews and maintenance is less 60% professional Android developers use Kotlin
  • 6. This work is licensed under the Apache 2.0 License Kotlin is an programming language that combines object-oriented programming and functional features into a unique platform. main() function - Entry point of the kotlin application function declaration –> fun keyword Example : fun main(args:Array<string>) { println(“Welcome to Compose Camp ”) } main() FUNCTION :-
  • 7. This work is licensed under the Apache 2.0 License VARIABLES :- Variables in kotlin :- A simple Box in which we can hold the data. There are mainly two types of variables in Kotlin: 1. var 2. val var and val :- ● var can be reassigned. ● val can’t be reassigned.
  • 8. This work is licensed under the Apache 2.0 License Data Types in Kotlin :- There are mainly Four types of data types: 1. Integer 2. Floating Point 3. Boolean 4. Character fun main () { var score :Int= 12 var température:Double=89.4 var isRaining:Boolean = false var alphabet: char=’A’ var message: string=”Hello World” }
  • 9. This work is licensed under the Apache 2.0 License Control Flow :- if-else :- if (condition) { // Run this code if condition is true } else { // Run this code if condition is false }
  • 10. This work is licensed under the Apache 2.0 License Control Flow :- When :- It is similar to switch case which is used in C/C++. Readability of code is more than if-else statement. fun main ( ) { val animal =”horse” // if (animal ==”Horse”) { //println(“Animal is Horse”) // } //else if (animal==”Cat”) { // println(“Animal is Cat”) } } when(animal) { “horse”->println(“Animal is Horse”) “Cat”->println(“Animal is Cat”) else -> println(“Animal not found”) } }
  • 11. This work is licensed under the Apache 2.0 License for Loop a for-loop is a control flow statement for specific iteration , which allows code to be executed repeatedly. LOOPS: fun main ( ) { for(item in 1…5) { println(item) } }
  • 12. This work is licensed under the Apache 2.0 License The while loop through a block of code as long a specified condition is true . while Loop:- fun main ( ) { while (condition) { // code block to be executed while // the condition is true } }
  • 13. This work is licensed under the Apache 2.0 License The do…while is similar to the loop with a difference that the this loop will executed to the code block once, before checking if the condition is true , then it will repeat the loop as long as the condition is true. do…while Loop:- fun main ( ) { do { // Body of the loop } while (condition) }
  • 14. This work is licensed under the Apache 2.0 License FUNCTIONS :- Block of code to perform certain functionality and helps to reuse the code Syntax of function :- fun functionName(par1,par2,....: ReturnType) { Block of statements return result } Example :
  • 15. This work is licensed under the Apache 2.0 License Let’s build this on Android Studio Add a button to App Add a button to App
  • 16. This work is licensed under the Apache 2.0 License Let’s build this on Android Studio Interacting with UI & state Interacting with UI &States
  • 17. This work is licensed under the Apache 2.0 License Earn digital badges For each quiz successfully passed
  • 18. This work is licensed under the Apache 2.0 License Carrie Sawyer See Developer Profile FAQ Badges are added to your Google Developer Profile
  • 19. This work is licensed under the Apache 2.0 License Milestones Attend sessions and workshops organised by GDSC BCE Patna Complete all the units under different tracks Build apps with Compose with the guidelines provided (app development guidelines coming soon)*
  • 20. This work is licensed under the Apache 2.0 License App submission Coming Soon !!
  • 21. This work is licensed under the Apache 2.0 License Compose Camp Week #2 Content Kotlin Fundamentals Add a button to App Interacting with UI &States
  • 22. This work is licensed under the Apache 2.0 License THANK YOU Google Developer Student Clubs Bakhtiyarpur College Of Engineering - Patna

Editor's Notes

  1. Results, Criteria,