Your Second Kotlin Android App

Aug 29 2023 · Kotlin 1.8.21, Android 13, Android Studio Flamingo | 2022.2.1

Part 2: Create Your Views

15. Challenge: Create an EmptyView

Episode complete

Play next episode

About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 14. Connect the Components to the Scaffold. Next episode: 16. Conclusion

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

In the previous episode, you prepared TaskListScreen but had no tasks to display. Instead of displaying a blank screen, you should show a view with the message No tasks yet**. In this challenge, you’ll an create an EmptyView Composable with the No tasks yet text and add it to the TaskListScreenContent.

fun EmptyView(message: String) {
        modifier = Modifier.fillMaxSize(),
        verticalArrangement = Arrangement.Center,
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
            imageVector = Icons.Default.List,
            contentDescription =  stringResource(id =,
            modifier = Modifier.size(100.dp)
        Spacer(modifier = Modifier.height(16.dp))
            text = message,
            style = MaterialTheme.typography.titleMedium

@Preview(showBackground = true)
fun EmptyViewPreview() {
    EmptyView(message = "No tasks yet")
fun TaskListContent(modifier: Modifier, tasks: List<TaskList>, onClick: (String) -> Unit) {
    if (tasks.isEmpty()) {
        EmptyView(message = stringResource(id = R.string.text_no_tasks))
    } else {
            modifier = modifier,
            content = {
                items(tasks) {
                        value =,
                        onClick = onClick