The listview is loaded 100 pictures from the internet using a thread pool. How load only elements 10 to the extent necessary? And when scrolldown loading another 10 items? I'm using Lru cache for this
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
It's all there hope you can take it from there.
no need to call all the data at once for your problem. you have to modify the api . make a webservice in such a way that only 10 data is shown at a time and this can be done by passing value from your app eg. during api calling pass 1 and server side should check if the value passed from android is 1 or 2 or... if the value is 1 (say) send 10 data using limit and if the value is 2 send another 10 data. and in android side during scrolling your list view call api passing value and append those fetched data from api to your local list and show those to the list view. It saves the time and userdata aswell
Its just matter of changing the data source
when the first time list view is loaded
Fetch some 10 images and add that in data source for list view adapter
If scrolling is detected then fetch next 10 images and clear the listview adapete and add this new 10 again
or you can fetch all the image urls in one shot then according to the scrolling you can change the contents of data source of list view adapter
You can use
limit
andoffset
for this:Example:
suppose i want to fetch 10 records and after end the scroll will fetch another 10 records:
Define the offset variable:
when you bind the adapter at that pass the offset variable:
So this will fetch only 10 records from 0-9 after that write below code for listview:
so when go you to last position of list view item at that time it will call the method
fetchrecords()
and youroffset value is 10
.So when this method calls at that time your offset value is 10.
so for next time your query is like:
So it will fetch other next 10 records.
Its done!!