MP1: Search and Callbacks

Created By: Geoffrey Challen
/ Updated: 2022-05-23

This lesson wraps up MP1. Our last step is to get the search bar in our main activity working. But before we do that, we need to discuss the idea of callbacks, a programming pattern central to building user interfaces.

The Android Framework

What exactly is Android, and what is a framework? Let's discuss this a bit, since it will help frame our discussion of callbacks that follows.

UI Event Callbacks

It's common in user interface programming to need to respond somehow to some interaction that the user has with the display. Maybe they click on something, or push a button, or add text into an input box. A canonical programming pattern for handling these events uses the idea of a callback or callback function. Let's explore that together and it will lead us right to our final task for MP1.

Enabling the Search Bar

Now let's look at exactly what we need to do to get our search bar to work!

Understanding the Initial List Population

Before we finish, let's apply what we've learned to understanding an unusual piece of code that you may have noticed in the MP starter code.

No Homework for This Lesson

As a reminder, on lessons where we focus on the machine project we will not assign a homework problem! However, the lesson will usually focus on helping you complete a particular part of the MP test suite, and so we encourage you to spend time on that in lieu of a homework problem.

Right now your goal should be to finish MP1 by enabling the search bar. Once you do, you're done. Congratulations! As always, if you get stuck, find us for help on the help site or forum.

MP1 Scores

More Practice

Need more practice? Head over to the practice page.