mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-26 17:53:14 +00:00
Adapter実装修正
This commit is contained in:
parent
874946a38d
commit
5f0e88d804
|
@ -7,8 +7,20 @@ import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.fragment.app.FragmentPagerAdapter;
|
import androidx.fragment.app.FragmentPagerAdapter;
|
||||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class ViewerViewPagerAdapter extends FragmentStateAdapter {
|
public class ViewerViewPagerAdapter extends FragmentStateAdapter {
|
||||||
|
|
||||||
|
// Variables
|
||||||
|
private ArrayList<Fragment> fragmentArrayList = new ArrayList<>();
|
||||||
|
private ArrayList<String> fragmentTitleList = new ArrayList<>();
|
||||||
|
|
||||||
|
// Setter
|
||||||
|
public void addFragment(Fragment fragment, String title){
|
||||||
|
fragmentArrayList.add(fragment);
|
||||||
|
fragmentTitleList.add(title);
|
||||||
|
}
|
||||||
|
|
||||||
public ViewerViewPagerAdapter(@NonNull FragmentActivity fragmentActivity) {
|
public ViewerViewPagerAdapter(@NonNull FragmentActivity fragmentActivity) {
|
||||||
super(fragmentActivity);
|
super(fragmentActivity);
|
||||||
}
|
}
|
||||||
|
@ -16,11 +28,11 @@ public class ViewerViewPagerAdapter extends FragmentStateAdapter {
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Fragment createFragment(int position) {
|
public Fragment createFragment(int position) {
|
||||||
return null;
|
return fragmentArrayList.get(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return 0;
|
return fragmentArrayList == null ? 0 : fragmentArrayList.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user