I have a ViewPager with 3 pages. In each page, I would like to insert a listview which is populated in seperate classes. Now, I found the simplest method is by inflate layouts which has a fragment in it. Lets say I have 3 pages. In page 1 I inflate a layout with fragment1, in page 2 I inflate a layout with fragment2, and in page 3 I inflate a layout with fragment3. How do I assign activities as the fragments contents? I have been searching through the internet for tutorials but none really fits my needs. Or are there any better way to achieve my goal?
Illustration:
Activity 1 2 and 3 are all ListViews. The inflate custom layouts as their itemslayout.
How do I assign activities as the fragments contents?
You don't. Activities hold fragments, not the other way around.
Or are there any better way to achieve my goal?
Use a ListFragment
for each page of your ViewPager
. Beyond that, you have not explained what your goal is, and therefore it is difficult to assist you further.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With