Lab 1 built each screen: XML, then Java changed the views. Here one Kotlin function says what the screen shows, and Compose draws it again when the data changes.
What you rebuild: Lab 1’s two screens, pixel for pixel, in one activity.
Built, then described
The same count, “Notes 3”, both ways. Lab 1 changed the views after each add and delete. Lab 2 writes one function that reads the list; when the list changes, Compose calls it again. Every part opens with the two ways side by side.
Lab 1 · Java changes the views
kotlin+java › com.yourname.notes ›MainActivity.javaRead only
I can read Kotlin beside Java, and create and run the Compose project.
0.1Read the Kotlin sheet
0.2Start a project with Empty Activity
0.3Fill in the form, keep Lab 1’s package
0.4Run it once
30 min, homeOpen Part 0
Other versions, older tutorials? 1 min
Tested with Android Studio Rabbit 2 (2026.2.2) and the Android 17 emulator (API 37), November 2026.
The lab is built on the versions the wizard writes: AGP 9.5.2, Kotlin 2.2.10, Compose BOM 2026.02.01. Accept no version update.
Old tutorials say “Empty Compose Activity”. In Rabbit 2, Empty Activity is the Compose template, and Empty Views Activity the XML one.
AGP 9 builds Kotlin itself: the project has no org.jetbrains.kotlin.android plugin line, unlike older projects.
Navigation Compose now receives only critical fixes. It still works, and it is what Android’s guide recommends for a Compose app. Navigation 3 is the new library: see Go further.
From Compose 1.13, BasicTextField(value, onValueChange) is deprecated in favour of BasicTextField(state). This lab uses 1.10: nothing is struck through. See Go further.
When Part 0 is done
Without JavaScript, the code says com.yourname.notes: replace yourname by the name you chose.
In class: NotesCompose opens, and “Hello Android!” runs on the phone, in place of Lab 1’s Notes.
That’s all for tonight.
Session 1: describe the screen
In class · Parts 1–4 · about 2 hDone
You leave with the styled notes screen and its three seed cards, drawn from a list.
I can open a second screen in the same activity, and share a note.
27 minOpen
In every part
Where you work
Android StudioYou write Kotlin in kotlin+java, and a few lines of res/.
PreviewDraws a composable function without the phone (Part 1).
The emulatorRuns the same Notes as Lab 1, under the same package.
LogcatShows when the activity starts, and when a function draws again (Part 6).
Amber: your code. Sky: the system and the phone. Each step names its places before you act.
Typethe short lines that carry an idea: a container, a state, a route. Android Studio’s completion helps (Ctrl+Space); no AI assistant.
Pastethe long pieces, with the Copy button of the code panel. Each panel starts with its imports: paste them first.
Quick check
Six questions on the whole lab, at the end of session 2. Answer, then see why.
Which line does Lab 2’s MainActivity use instead of setContentView(R.layout.activity_main)?
See the answer
setContent hands the activity a composable function: there is no layout file to inflate. @Preview only draws a function in the IDE (Part 1).
In Modifier.padding(16.dp).background(Brand), where is the 16 dp of space?
See the answer
The links apply in order. A padding before background is a margin; after it, a padding (Part 2).
Since Part 2, Title refuses your letters. Why?
See the answer
The field draws the value it is given. onValueChange = { title = it } stores your letter in a state; the state changes, and Compose draws the field again (Part 5).
You type one letter in Title. What runs again?
See the answer
Logcat shows one “NotesScreen draws” per letter, and no “Main onCreate”. A recomposition is not a recreation (Part 6).
After a rotation, your half-typed title is still there, but the notes you added are gone. Why?
See the answer
A rotation recreates the activity. What remember kept starts again from the seeds; rememberSaveable keeps the title, as Lab 1’s EditText did. Keeping the notes is the next milestone (chapters 03 and 09).
You tap a card and the note page opens. What happened to the activity?
See the answer
One activity, two routes: navigate("note/$index") carries only the position, and both screens read the same list. The manifest does not change, and Logcat stays silent (Part 7).
Go further
After Part 7: for fast students in class, and for home. Three challenges, no steps: pick one.
The app speaks French
A challenge
Lab 2’s texts are English literals. Move them to res/values/strings.xml (Lab 1’s names: note_added, counter…), read each with stringResource(R.string.…), then add values-fr, as in Lab 1’s challenge “The app speaks French”. Two traps: inside onClick, stringResource is not allowed (it is @Composable): use context.getString(R.string.note_added), the same in onLongClick for note_deleted. The counter takes its number: stringResource(R.string.counter, body.length). The seeds sit outside functions: build them in NotesApp with context.getString(…).
A field that holds its own text
A challenge
Newer Compose replaces value and onValueChange with BasicTextField(state = rememberTextFieldState()). Rewrite NotesField that way, and the two states that feed it: the screen must look exactly the same. Look up clearText() and InputTransformation.maxLength(140).
Navigation 3
A challenge
In Navigation 3, the back stack is a list you own, and NavDisplay shows its last entry. Rebuild Part 7’s two screens with it: a key for the list, a key that holds the note’s position, the same Back. Add the androidx.navigation3 libraries at home: they download.
For the teacher The two sessions 1 min
Session 1, 91 min of steps. Open with the finished app, live, beside Lab 1’s (5 min). Parts 1 and 2, then sync point A (Lab 2’s own skeleton); a break; Part 3, sync point B (the styled screen, beside Lab 1’s); Part 4, sync point C (three cards).
Session 2, 84 min of steps. Part 5, sync point D (the input table); a break; Part 6; Part 7, then the quick check.
A beginner takes about 1.3 times the step minutes: about 2 h of work per session. A student who is behind starts the next part from its catch-up.
Running late? Skip the optional “Now you” boxes: Part 3’s palette, Part 7’s double tap. Still late? Let students paste a long step from its Stuck? fold instead of typing it. Never skip Part 5’s input table or Part 7’s Share.