0

I'm using Android Studio, and I have a listView that musts display an important amount of items. showing all of these items have a huge impact on performances. SO I would like to show them 10 by 10, and with a button show the 10 next items. After some researches, I found this android How to limit list items display in ListView and a button show more and this How to limit list items display in ListView by 10 and next 10after clicking next button. But these didn't lead me to a success. The 1st link looks easier but I didn't know where to put the code samples to make it work. Thanks for help !

Community
  • 1
  • 1
Jay
  • 144
  • 1
  • 2
  • 14
  • please try list view EndListListener https://github.com/codepath/android_guides/wiki/Endless-Scrolling-with-AdapterViews-and-RecyclerView – Ganesh Gudghe Jun 30 '16 at 10:43

2 Answers2

1

You dont need to show "Load More" Button always. You can use Android's Recycler View for this. It will load only the data which can be shown on screen. Rest of the data will be loaded as you scroll down. And the view which is scrolled up (Vanishing views) are recycled automatically.

Check this links https://developer.android.com/training/material/lists-cards.html https://guides.codepath.com/android/using-the-recyclerview https://www.binpress.com/tutorial/android-l-recyclerview-and-cardview-tutorial/156

John
  • 8,846
  • 8
  • 50
  • 85
  • I tried it but recycler view gave me recycling problem, if i scroll to see others items and go back up it changes my items.. – Jay Jun 30 '16 at 13:49
0

First link question have a simple answer, If you made a custom adapter for populating listview then there will be a getCount() method which will return the number of items you want to show on listview. if you have not getCount() method then simply override it.

Link

there i(variable) have that value which number if items you want to show on listview, on refresh button click increment the value of i(variable) that will again refresh the whole listview and add the total number of items in listview which is the value of i(variable)

Community
  • 1
  • 1
iub iub
  • 94
  • 6
  • yes but when i have my button listening in my main activity and I give him the variable i how do my custom adapter knows that i the the value to have in getCount ? – Jay Jun 30 '16 at 13:48