Creating BeatBox

Time to get started. The first step is to create your BeatBox app.

In Android Studio, select FileNewNew Project... to create a new project. Start with the Empty Activity option for Phone and Tablet. Call this app BeatBox and give it a package name of com.bignerdranch.android.beatbox. Select the option to Use AndroidX artifacts and leave the rest of the defaults as they are.

The activity will display a grid of buttons in a RecyclerView. Add the androidx.recyclerview:recyclerview:1.0.0 dependency to your app/build.gradle file (do not forget to sync the file). Replace the autogenerated contents of res/layout/activity_main.xml with a single RecyclerView.

Listing 19.1  Updating the layout file for MainActivity (res/layout/activity_main.xml)

<androidx.constraintlayout.widget.ConstraintLayout
        ...
        tools:context=".MainActivity">
        ...
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.recyclerview.widget.RecyclerView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

Run your app. You should see a blank screen, reassuring you that you plugged everything together correctly to this point. Pat yourself on the back before you dive into the new territory of data binding.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
44.204.24.82