Saved and Searched News Layouts
Learn how to create a search bar and a layout for displaying saved news.
We'll cover the following...
Saved news fragment
Create the SavedNewsFragment.kt
class and remove the boilerplate code before heading over to the layout file. This class will be used to observe and retrieve saved articles selected by the user and display them to the user in a list supported by the RecyclerView
.
Press + to interact
package com.example.ui.fragmentsimport android.os.Bundleimport androidx.fragment.app.Fragmentimport android.view.LayoutInflaterimport android.view.Viewimport android.view.ViewGroupimport com.example.newsapplication.Rclass SavedNewsFragment : Fragment(R.layout.fragment_saved_news) {override fun onViewCreated(view: View, savedInstanceState: Bundle?) {super.onViewCreated(view, savedInstanceState)}}
We add RecyclerView
in this layout, and the rest of the code remains the same, except when we add a RecyclerView
to handle the list of saved news. Normally, ...