8.5 MainActivity Class

This app consists of three classes:

  • Class MainActivity—which we discuss in this section—configures the app’s GUI and defines the app’s logic.

  • Class SearchesAdapter (Section 8.6) is a subclass of RecyclerView.Adapter that defines how to bind the tag names for the user’s searches to the RecyclerView’s items. Class MainActivity’s onCreate method creates an object of class SearchesAdapter as the RecyclerView’s adapter.

  • Class ItemDivider (Section 8.7) is a subclass of RecyclerView.ItemDecoration that the RecyclerView uses to draw a horizontal line between items.

Sections 8.5.18.5.10 discuss class MainActivity in detail. This app does not need a menu, so we removed the MainActivity methods onCreateOptionsMenu and onOptionsItemSelected ...

Get Android How to Program, 3/e 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.