Questions tagged [fragmentstateadapter]

35 questions
1
vote
0 answers

Data not refreshing on fragment recreation in ViewPager2 PagedList DiffUtil FragmentStateAdapter

I was trying to display Two sets of Product List in ViewPager tabs inside a fragment. I was also using Paging library. Able to get data loaded and pagination is also working fine. I was also able to invalidate and reload paged list data, if I am…
1
vote
0 answers

How to notifyItemRemove fragments in FragmentStateAdapter in viewpager2

I wanna remove item from viewpager2 adapter but when notify adapter(FragmentStateAdapter) activity crashed and give bellow error: java.lang.IndexOutOfBoundsException: Index: 36, Size: 36 at java.util.ArrayList.get(ArrayList.java:437) at…
mahdi
  • 21
  • 5
1
vote
0 answers

FragmentStateAdapter with ViewPager2 showing incorrect fragment

My app has an activity that displays a list of items using a RecyclerView. When a list item is selected, the UUID of the model object associated with that list item is sent as an intent extra to another activity that has a ViewPager2 adapter in its…
1
vote
1 answer

ViewPager2 with FragmentStateAdapter nested scrolling issue

I've setup my activity layout using ViewPager2, BottomNavigationView and Fragments. In my First fragment in ViewPager2 contains a ImageSlider. When I scroll the ImageSlider the entire fragment (in ViewPager2) scrolls to 2nd Fragment. Why is this…
1
vote
1 answer

Error : None of the following functions can be called with the arguments supplied issue in FragmentStateAdapter in viewpager2

See my code I am using viewpager 2 in a fragment to hold child fragments. There can be 'n' number of child fragments. It is showing lint error in adapter. //See my fragment code override fun onViewCreated(view: View, savedInstanceState: Bundle?) { …
0
votes
0 answers

viewPager2 FragmentStateAdapter createFragment only call once

Here is my activity and fragment architecture MainActivity Fragment_A Fragment_B Fragment_C viewPager2 -pageA = ChartFragment.instance("1") -pageB = ChartFragment.instance("2") -pageC = ChartFragment.instance("3") When I change Fragment to…
Shao
  • 11
  • 5
0
votes
0 answers

The ensureFragment method of FragmentStateAdapter threw a null pointer exception

My code is as follows private List fragments; public HomeFragmentAdapter(FragmentActivity fragmentActivity, List fragments) { super(fragmentActivity); this.fragments = fragments; } …
0
votes
0 answers

Android FragmentStateAdapter loads wrong page

I have a ViewPagerAdapter that extends FragmentStateAdapter. The code below showcases said adapter. public class ViewPagerAdapter extends FragmentStateAdapter { public ViewPagerAdapter(@NonNull FragmentManager fragmentManager, @NonNull…
0
votes
0 answers

Updating contents in view created by Fragment in Android Studio

I have a Fragment that is created through a FragmentStateAdapter. The Fragment creates a view on Android Studio. I was wondering if there is a way to updates contents of the view that is generated dynamically? Say I receive some data from a server…
0
votes
0 answers

ViewPager2 data lost when coming back from next fragment in tab layout

I am using Tab layout with Fragment State Adapter.My problem is viewPager2 lost data when I jumped from more than 2 fragments back or ahead. Please resolve it...
0
votes
1 answer

ViewPager2, FragmentStateAdapter, and conflict between pager's currentItem and adapter's createFragment's position parameter

When implementing ViewPager2 and its associated FragmentStateAdapter for its contents in Kotlin, I ran into a weird issue: It has to do with the adapter's createFragment(position: Int) method and viewPager2's setCurrentItem(item: Int, smoothScroll:…
0
votes
1 answer

Broken TabLayout due to ViewPager2

I have a Tablayout with 2 tabs (fragments) Home and Contacts, implemented using aViewPager2. The data in each fragment (an update is requested on each onResume() of the TabLayout Activity).Since i have to call adapter.notifyItemChanged(position); to…
0
votes
1 answer

How to update fragmentStateAdapter after a bottomSheet dismiss

I have this fragmentStateAdapter which holds some of my Cards in order to swipe among them: public class ScreenSlidePagerAdapter(activity: AppCompatActivity, var items: ArrayList, private val saveToDb: Boolean) :…
0
votes
1 answer

FragmentStateAdapter and ViewPager2 is loading fragment slower than FragmentStatePagerAdapter and ViewPager

In my app, am showing list of month calendar which can be scrollable to previous and next month. While swiping to previous and next, my fragments are loading smoothly and without any delay if I use FragmentStatePagerAdapter and ViewPager but it's…
0
votes
1 answer

Fragment instances are kept in viewPager2 when host fragment removed

Have one activity app, where I have HomeFragment from which I open HostFragment, and HostFragment has ViewPager2 with 3 fragment items TabFragment1, TabFragment2 and TabFragment3. When I open the HostFragment, and then go back, my tabFragments'…