Composable Functions

Before you create the scrollable list of toppings, there is a bit of housekeeping to take care of. Right now, your entire UI is defined in your Activity. This can get unwieldy quickly, especially for large applications. You can break your UI into smaller chunks by refactoring your Compose code into functions.

Composables’ names, like Row and Column, begin with capital letters – just like the names of framework views like Button and ImageView. But composables are not classes, like views: They are functions.

Remember when we said you cannot get a reference to a Compose UI element or call findViewById on one? No classes means there is nothing that can be referenced. At runtime, with some help from the Compose ...

Get Android Programming: The Big Nerd Ranch Guide, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.