From the course: Android Studio Essential Training 2020

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Challenge: Extract code to a new class

Challenge: Extract code to a new class

From the course: Android Studio Essential Training 2020

Start my 1-month free trial

Challenge: Extract code to a new class

(upbeat electronic music) - [Instructor] Here's a simple challenge to test your understanding of how to modify code in Android Studio. First, create a new Android Studio project, and I'll use a template I haven't used before in this course. It'll be based on an activity template labeled Scrolling Activity. I'll name the new project Scrolling Activity, and then create it. When this project opens, you'll see the Scrolling Activity class. Now here's the very simple goal. That there's a bit of code in the onCreate function. Your job is to extract that code and place it into its own function. Call the function InitLayout. When you're done, you should have a new function named InitLayout that has all this code, and you should also have a call to that new function in the onCreate function. Don't do this manually, use Android Studio's refactoring tools to extract the code to a new function. When you're done, take a…

Contents