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.fragments
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.example.newsapplication.R
class 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, ...