android_basics_with_compose
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| android_basics_with_compose [2025/05/23 11:22] – kalaschnikow | android_basics_with_compose [2025/12/26 16:53] (current) – [Unit 3: Display lists and use Material Design] kalaschnikow | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Android Basics with Compose ====== | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | * Course goals: | ||
| + | * Understand the fundamentals of Kotlin and Jetpack Compose | ||
| + | * Build a series of basic Android apps | ||
| + | * Use Android app architecture, | ||
| + | |||
| + | |||
| + | * Also interesting courses | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | |||
| + | |||
| + | * Kotlin Playground: | ||
| + | * https:// | ||
| + | * the same: https:// | ||
| + | |||
| + | ===== Unit 1: Your first Android app ===== | ||
| + | |||
| + | ==== Pathway 1: Introduction to programming in Kotlin ==== | ||
| + | |||
| + | https:// | ||
| + | |||
| + | === 1. Before you begin === | ||
| + | * ... | ||
| + | * multiple " | ||
| + | * for newbies | ||
| + | * for existing programmers | ||
| + | * ... | ||
| + | |||
| + | === 2. Welcome to Android Basics with Compose === | ||
| + | ... | ||
| + | |||
| + | === 3. Your first program in Kotlin === | ||
| + | |||
| + | * Playground: | ||
| + | * https:// | ||
| + | * the same: https:// | ||
| + | |||
| + | <code kotlin> | ||
| + | fun main() { | ||
| + | println(" | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | * A Kotlin program requires a '' | ||
| + | * To define a function in Kotlin, use the '' | ||
| + | * The name of a function should follow camel case convention and start with a lowercase letter. | ||
| + | * Use the println() function call to print some text to the output. | ||
| + | * Refer to the [[https:// | ||
| + | * Troubleshooting is the process of resolving errors in your code. | ||
| + | |||
| + | === 4. Create and use variables in Kotlin === | ||
| + | |||
| + | < | ||
| + | val count: Int = 2 | ||
| + | </ | ||
| + | |||
| + | Type inference: | ||
| + | < | ||
| + | val count = 2 | ||
| + | </ | ||
| + | |||
| + | If you need to update the value of a variable, declare the variable with the Kotlin keyword var, instead of val: | ||
| + | < | ||
| + | var cartTotal = 0 | ||
| + | cartTotal = 20 | ||
| + | println(" | ||
| + | </ | ||
| + | |||
| + | |||
| + | * A variable is a container for a single piece of data. | ||
| + | * You must declare a variable first before you use it. | ||
| + | * Use the '' | ||
| + | * Use the '' | ||
| + | * In Kotlin, it's preferred to use '' | ||
| + | * To declare a variable, start with the '' | ||
| + | * With type inference, omit the data type in the variable declaration if an initial value is provided. | ||
| + | * Some common basic Kotlin data types include: '' | ||
| + | * Use the assignment operator ('' | ||
| + | * You can only update a variable that has been declared as a mutable variable (with '' | ||
| + | * Use the increment operator ('' | ||
| + | * Use the '' | ||
| + | |||
| + | * Calculations in String templates: | ||
| + | <code kotlin> | ||
| + | fun main() { | ||
| + | val numberOfPhotos = 100 | ||
| + | val photosDeleted = 10 | ||
| + | println(" | ||
| + | println(" | ||
| + | println(" | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | === 5. Create and use functions in Kotlin === | ||
| + | |||
| + | By default, if you don't specify a return type, the default return type is '' | ||
| + | |||
| + | Any function that doesn' | ||
| + | |||
| + | * Functions are defined with the fun keyword and contain reusable pieces of code. | ||
| + | * Functions help make larger programs easier to maintain and prevent the unnecessary repetition of code. | ||
| + | * Functions can return a value that you can store in a variable for later use. | ||
| + | * Functions can take parameters, which are variables available inside a function body. | ||
| + | * Warning: Unlike in some languages, such as Java, where a function can change the value passed into a parameter, parameters in Kotlin are immutable. You cannot reassign the value of a parameter from within the function body. | ||
| + | * Arguments are the values that you pass in when you call a function. | ||
| + | * You can name arguments when you call a function. When you use named arguments, you can reorder the arguments without affecting the output. | ||
| + | <code kotlin> | ||
| + | birthdayGreeting(name=" | ||
| + | // the same: | ||
| + | birthdayGreeting(age=2, | ||
| + | </ | ||
| + | * You can specify a default argument that lets you omit the argument when you call a function. | ||
| + | <code kotlin> | ||
| + | fun birthdayGreeting(name: | ||
| + | // function body here... | ||
| + | } | ||
| + | |||
| + | // call function with two parameters | ||
| + | birthdayGreeting(" | ||
| + | |||
| + | // call function with only one parameter, but delivers the same result: | ||
| + | birthdayGreeting(age=2) | ||
| + | |||
| + | </ | ||
| + | |||
| + | === 6. Practice Problems: Kotlin Basics === | ||
| + | |||
| + | ... | ||
| + | |||
| + | More Kotlin exercises can be found in [[https:// | ||
| + | |||
| + | === 7. What's next === | ||
| + | |||
| + | (Optional video) | ||
| + | |||
| + | |||
| + | ==== Pathway 2: Setup Android Studio ==== | ||
| + | |||
| + | https:// | ||
| + | |||
| + | === 1. Introduction to Android Studio === | ||
| + | ... | ||
| + | |||
| + | === 2. Download and install Android Studio === | ||
| + | ... | ||
| + | |||
| + | === 3. Create your first Android app === | ||
| + | ... | ||
| + | |||
| + | * The '' | ||
| + | |||
| + | * You add the '' | ||
| + | * '' | ||
| + | * '' | ||
| + | |||
| + | * The '' | ||
| + | |||
| + | ... | ||
| + | * Summary | ||
| + | * ... | ||
| + | * Composable functions are like regular functions with a few differences: | ||
| + | * A '' | ||
| + | |||
| + | |||
| + | === 4. Run your first app on the Android Emulator === | ||
| + | ... | ||
| + | |||
| + | === 5. How to connect your Android device === | ||
| + | ... | ||
| + | |||
| + | |||
| + | ==== Pathway 3. Build a basic layout ==== | ||
| + | |||
| + | https:// | ||
| + | |||
| + | === 1. Intro to Jetpack Compose === | ||
| + | |||
| + | (Optional video) | ||
| + | |||
| + | |||
| + | === 2. Design a birthday card app === | ||
| + | |||
| + | (Optional video) | ||
| + | |||
| + | === 3. Build a simple app with text composables === | ||
| + | |||
| + | https:// | ||
| + | |||
| + | * Jetpack Compose is a modern toolkit for building Android UIs. | ||
| + | * Compose - UI written in Kotlin | ||
| + | * => simplifies and accelerates UI development on Android with less code, powerful tools, and intuitive Kotlin capabilities. | ||
| + | * build your UI by defining a set of functions, called composable functions, that take in data and describe UI elements. | ||
| + | * Composable: | ||
| + | * Describes some part of your UI. | ||
| + | * Doesn' | ||
| + | * Takes some input and generates what's shown on the screen. | ||
| + | * All composable functions must have '' | ||
| + | * Annotations | ||
| + | * without parameters | ||
| + | * '' | ||
| + | * with parameters | ||
| + | * '' | ||
| + | * Composable naming | ||
| + | * MUST be a noun | ||
| + | * PascalCase, NOT camelCase | ||
| + | * Composable preview | ||
| + | * must provide default value for any parameter to preview it | ||
| + | |||
| + | ... | ||
| + | * scalable pixels | ||
| + | * sp -> scalable pixels | ||
| + | * dp -> density independent pixels | ||
| + | |||
| + | ... | ||
| + | * UI hierachy (Parent <-> Child) | ||
| + | * '' | ||
| + | ... | ||
| + | * Trailing lambda syntax | ||
| + | * If the function is the last parameter in (an another) function, instead of putting the function inside the parentheses, | ||
| + | < | ||
| + | Row( | ||
| + | content = { | ||
| + | Text(" | ||
| + | Text(" | ||
| + | } | ||
| + | ) | ||
| + | |||
| + | // the same in trailing lambda syntax: | ||
| + | Row { | ||
| + | Text(" | ||
| + | Text(" | ||
| + | } | ||
| + | </ | ||
| + | ... | ||
| + | |||
| + | === 4. Add images to your Android app === | ||
| + | |||
| + | https:// | ||
| + | |||
| + | ... | ||
| + | |||
| + | * The Resource Manager tab in Android Studio helps you add and organize your images and other resources. | ||
| + | * An Image composable is a UI element that displays images in your app. | ||
| + | * An Image composable should have a content description to make your app more accessible. | ||
| + | * Use '' | ||
| + | * '' | ||
| + | * Text that's shown to the user, such as the birthday greeting, should be extracted into a string resource to make it easier to translate your app into other languages. | ||
| + | |||
| + | === 5. Practice: Compose Basics === | ||
| + | ... | ||
| + | |||
| + | === 6. Project: Create a business card app === | ||
| + | |||
| + | ... | ||
| + | |||
| + | |||
| + | ===== Unit 2: Building app UI ===== | ||
| + | |||
| + | https:// | ||
| + | |||
| + | * [[Pathway 1 Kotlin fundamentals|Pathway 1: Kotlin fundamentals]] | ||
| + | * (my conspectus of https:// | ||
| + | * [[Pathway 2 Add a button to an app|Pathway 2: Add a button to an app]] | ||
| + | * (my conspectus of https:// | ||
| + | * [[Pathway 3 Interact with UI and state|Pathway 3: Interact with UI and state]] | ||
| + | * (my conspectus of https:// | ||
| + | |||
| + | ===== Unit 3: Display lists and use Material Design ===== | ||
| + | |||
| + | https:// | ||
| + | |||
| + | * [[Pathway 1 More Kotlin fundamentals|Pathway 1: More Kotlin fundamentals]] | ||
| + | * (my conspectus of [[https:// | ||
| + | * [[Pathway 2 Build a scrollable list|Pathway 2: Build a scrollable list]] | ||
| + | * (my conspectus of [[https:// | ||
| + | * [[Pathway 3 Build beautiful apps|Pathway 3: Build beautiful apps]] | ||
| + | * (my conspectus of [[https:// | ||
| + | |||
| + | ===== Unit 4: Navigation and app architecture ===== | ||
| + | |||
| + | ... | ||
| + | |||
| + | ===== Unit 5: Connect to the internet ===== | ||
| + | |||
| + | ... | ||
| + | |||
| + | ===== Unit 6: Data persistence ===== | ||
| + | |||
| + | ... | ||
| + | |||
| + | ===== Unit 7: WorkManager ===== | ||
| + | |||
| + | ... | ||
| + | |||
| + | ===== Unit 8: Views and Compose ===== | ||
| + | |||
| + | ... | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
