From 5f0e88d804ddd19a181156430292d4c9e9991e27 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 28 Jan 2024 12:54:41 +0900 Subject: [PATCH] =?UTF-8?q?Adapter=E5=AE=9F=E8=A3=85=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/viewer/ViewerViewPagerAdapter.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java index 5de859c6..cdf742b0 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java @@ -7,8 +7,20 @@ import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentPagerAdapter; import androidx.viewpager2.adapter.FragmentStateAdapter; +import java.util.ArrayList; + public class ViewerViewPagerAdapter extends FragmentStateAdapter { + // Variables + private ArrayList fragmentArrayList = new ArrayList<>(); + private ArrayList fragmentTitleList = new ArrayList<>(); + + // Setter + public void addFragment(Fragment fragment, String title){ + fragmentArrayList.add(fragment); + fragmentTitleList.add(title); + } + public ViewerViewPagerAdapter(@NonNull FragmentActivity fragmentActivity) { super(fragmentActivity); } @@ -16,11 +28,11 @@ public class ViewerViewPagerAdapter extends FragmentStateAdapter { @NonNull @Override public Fragment createFragment(int position) { - return null; + return fragmentArrayList.get(position); } @Override public int getItemCount() { - return 0; + return fragmentArrayList == null ? 0 : fragmentArrayList.size(); } }