简体   繁体   中英

Using ViewPager2 in an Existing Fragment

I have Created a Fragment for my bottom Tab bar, The tab bar has four fragments, In one of my fragments, I am in need of Slider to view testimonials of people one by one. In this case, I have used the ViewPager2 functionality to work on the slider, I have all the steps to create Viewpager2 from this video

https://youtu.be/KwihiADN-0k

After following all the steps I have getting an error stating

java.lang.IllegalStateException: viewpager1 must not be null (viewpager1 is my id of Viewpager2 function)

你应该定义你的 viewpager1.adapter = viewpager1Adapter 不是在 onCreateView() 中,而是在 onViewCreated() 中,你的问题将得到解决。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM