0

I want to create one screen in application where i have list of items (ListFragment) which have one button named "Next".

For a Example I have 50 items in my arraylist, here i want to load first 5 or 6 items for first list when user click on next then user can see next 6 to 12 items. this manner it will continue till 50. This List fragment should not have vertical scroll.

These 50 items is dynamic sometimes it would be 5 only sometimes 10 or sometimes 25.

So here how can i load this type of view in ListFragment with viewpager.?

Please some one guide to how can i achieve this.

Thanks & Regards

sam_k
  • 5,983
  • 14
  • 76
  • 110
  • Start here https://developer.android.com/training/basics/fragments/index.html and download the FragmentBasics.zip project. Implementing Fragments in a ViewPager is not trivial so make sure you read and understand what's going in the Android docs. – samus Jun 11 '14 at 12:52
  • http://stackoverflow.com/questions/5710573/need-a-fragments-example – samus Jun 11 '14 at 12:57
  • Here is a succinct example in Mono/C# http://stackoverflow.com/questions/13501424/fragmentpageradapter-exists-only-in-android-support-v4-app-and-not-android-app – samus Jun 11 '14 at 13:00

1 Answers1

0

You could just use an ArrayAdapter for your ListView and give it the 6 to 12 items you want to display.

When the user clicks on 'next', you can replace the items in the ArrayAdapter and call notifyDataSetChanged() on it, to let it redraw itself.

tknell
  • 9,007
  • 3
  • 24
  • 28
  • Thanks for your answer. But i can not do auto manage those things? I have to do manually by code to set 1 to 6 items and 6 to 12 items etc. As my items are not fixed sometimes only 2 items would also be there. – sam_k Jun 12 '14 at 04:10
  • You can add as many items to the adapter as you like, if you have 50, set 6 to 12, and load other items on 'next'. If you have only two items, just set the two. Not much different to using multiple lists and a ViewPager, but much simpler. – tknell Jun 13 '14 at 10:02