ViewPager2 with fragments lazy inflation

Usually, we use viewStubs in the fragments to lazily inflate complex views when using with view pager using the fragment’s setUserVisibleHint() method which is called by the PagerAdapter when fragment is going to be visible to user.

Now comes viewPager2, that needs a recyclerview adapter or viewPager2.FragmentStateAdapter if holders are fragments.
How to lazily inflate the fragments in this viewpager2 ? More specifically, is it possible to use viewStubs in for viewHolders and only inflate them from bindViewHolder ?

I am unconvinced that setUserVisibleHint() is reliable in this context.

I have no idea. I have not used ViewPager2, and I don’t lazily inflate layouts.

I have no idea.

I am sorry that I cannot be of greater assistance on this topic!