Questions tagged fragmentstateadapter

Explore the latest questions and answers asked by our top developers.

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 refresh the fragments, i had to overrite both getItemId and containsItem in my FragmentStateAdpater as explained in the blue […]

Dagger2 ViewModel not destroyed when fragment destroyed

in my project I am using Dagger2 to inject ViewModels into fragments. override val viewModel: AllStockListTabViewModel by viewModels ({this}, {viewModelFactory}) To briefly explain my situation, I have a fragment that uses fragment state adapter which contains two fragments. For convinience, I’ll call the parent fragment fragment A and child fragments in fragment state adapter fragment […]

By
Published
Categorized as android, dagger-2, fragmentstateadapter, kotlin, viewmodel

Dagger-Android: ViewModel not destroyed when fragment destroyed

in my project I am using Dagger2 to inject ViewModels into fragments. override val viewModel: AllStockListTabViewModel by viewModels ({this}, {viewModelFactory}) To briefly explain my situation, I have a fragment that uses fragment state adapter which contains two fragments. For convinience, I’ll call the parent fragment fragment A and child fragments in fragment state adapter fragment […]

By Austin
Published
Categorized as android, dagger-2, fragmentstateadapter, kotlin, viewmodel

How to refresh/reload fragment that have viewpager2 and FragmentStateAdapter(fragmentActivity)

I am building an app barcode/rfid app that has 3 fragments. I would like to reload FragmentB from FragmentA. Any time user scans a barcode and add its to sqlite db in FragmentA, it should refresh the list in FragmentB. Fragment B is using sqlite db to show all the barcode. At this moment, Fragment […]

FragmentStateAdapter crashes app building slides

The on-boarding of my Android app is built using a FragmentStateAdapter, this is the first view the users sees after installing the app, a list of slides. On some users the app crashes trying to show the first slide because the list of slides is still empty. I’ve reviewed the code and I can’t find […]

By Wonton
Published
Categorized as android, fragmentstateadapter

ViewPager2 within Fragment does not display Fragments

I’m having an issue with setting up ViewPager2 within a Fragment. I’ve done everything correctly as far as I can tell, but the Fragments I want to display in the hosting fragment do not display at all. Here is my adapter: class RepsViewPagerAdapter(supportFragmentManager: FragmentManager, lifecycle: Lifecycle): FragmentStateAdapter(supportFragmentManager,lifecycle) { private val fragments = arrayListOf(NationalRepsFragment(),StateRepsFragment(),CityRepsFragment()) val titles […]

How do i Refresh or Completely add new FragmentStateAdapter after returning back to Activity?

I’m trying to refresh my FragmentStateAdapter (CultivationMainViewAdapter) fragments to update list when user is returned back from second activity just after creating or updating a list item. For example in first activity i have 2 tabs named workers_list tab and notes tab. when any workers_list item is selected then new activity is opened to view […]

By kattie
Published
Categorized as adapter, android, android-fragments, firebase, fragmentstateadapter

Refresh or Completely Renew FragmentStateAdapter after returning back to Activity?

I’m trying to refresh my FragmentStateAdapter (CultivationMainViewAdapter) fragments to update list when user is returned back from second activity just after creating or updating a list item. For example in first activity i have 2 tabs named workers_list tab and notes tab. when any workers_list item is selected then new activity is opened to view […]

By kattie
Published
Categorized as adapter, android, android-fragments, firebase, fragmentstateadapter

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<Helpers.Card>, private val saveToDb: Boolean) : FragmentStateAdapter(activity) { override fun getItemCount(): Int = items.count() var fragment:CardItemFragment?=null override fun createFragment(position: Int): Fragment{ fragment =CardItemFragment(position, saveToDb ,this) //.newInstance( items[position ].getSaveString()) return fragment as CardItemFragment }} […]

By Askcomp eugi-tech
Published
Categorized as android, fragmentstateadapter

How to replace a fragment in a FragmentStateAdapter

I have a "main" fragment that contains tabs on the side, and when I click on any of those tabs, the ViewPager2 of the "main" fragment jumps to the specific fragment (each fragment is of a different class) in the FragmentStateAdapter. Let’s say that for one of those fragments, it has a button where if […]

1 2 3

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq