July 2018
Intermediate to advanced
266 pages
7h 11m
English
Now we need to have the UI perform the search and display the results. First, we need to add a search() function to be called when the button is clicked, and we also want to add the variables for the recycler view, the adapter, and the layout manager:
class SearchActivity : AppCompatActivity() { private lateinit var articles: RecyclerView private lateinit var viewAdapter: ArticleAdapter private lateinit var viewManager: RecyclerView.LayoutManager ... private suspend fun search() { // TODO: Implement search function }}
To add the click listener, we just need to update the onCreate() function. Let's take this opportunity to also instantiate some of the added variables:
override fun onCreate(savedInstanceState: Bundle ...
Read now
Unlock full access