From c1d5a3e8fb8b3f8ac28d1e7818b5b33c0ab41b49 Mon Sep 17 00:00:00 2001 From: Clyhtsuriva Date: Wed, 17 Feb 2021 22:57:15 +0100 Subject: Recycler view now working in a fragment. --- app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt | 21 ++++++++++++--------- app/src/main/res/layout/item_layout.xml | 2 +- app/src/main/res/values/strings.xml | 1 + 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt b/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt index 17d124e..ac585c7 100644 --- a/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt +++ b/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt @@ -1,13 +1,13 @@ package xyz.adjutor.aniki import android.os.Bundle -import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.Button -import androidx.appcompat.app.AppCompatActivity +import androidx.fragment.app.Fragment import androidx.navigation.fragment.findNavController +import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView class TopMangaPage : Fragment() { @@ -17,7 +17,16 @@ class TopMangaPage : Fragment() { savedInstanceState: Bundle? ): View? { // Inflate the layout for this fragment - return inflater.inflate(R.layout.top_manga_page, container, false) + val view = inflater.inflate(R.layout.top_manga_page, container, false) + + // Retrieves data from mangasource + val mangaList = MangaSource(view.context).getMangaList() + + val recyclerView: RecyclerView = view.findViewById(R.id.recycler_view) + recyclerView.setHasFixedSize(true) + recyclerView.layoutManager = LinearLayoutManager(view.context) + recyclerView.adapter = MangaAdapter(mangaList) + return view } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -27,11 +36,5 @@ class TopMangaPage : Fragment() { findNavController().navigate(R.id.action_TopMangaPage_to_HomePage) } - // Retrieves data from mangasource - val mangaList = MangaSource(requireActivity().applicationContext).getMangaList() - - val recyclerView: RecyclerView = view.findViewById(R.id.recycler_view) - recyclerView.adapter = MangaAdapter(mangaList) - } } \ No newline at end of file diff --git a/app/src/main/res/layout/item_layout.xml b/app/src/main/res/layout/item_layout.xml index af4b9b0..8500bc7 100644 --- a/app/src/main/res/layout/item_layout.xml +++ b/app/src/main/res/layout/item_layout.xml @@ -39,7 +39,7 @@ app:layout_constraintBottom_toBottomOf="parent" android:text="@string/rv_title" android:textColor="@color/strong_pink" - android:textSize="30sp"/> + android:textSize="20sp"/> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 41bd064..d69fb60 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -31,6 +31,7 @@ Ana Satsujin Samurai Deeper Kyou Sebsei, Ore ni Kamawazu Itte Kudasai!! + Mondaiji-tachi ga Isekai Kara Kuru Sou Desu yo Dragon Ball -- cgit v1.2.3