Reputation: 2191
as im loading lots of data from en external db to my android app (through a web service), i would like to show like 20 items per page because some queries get like hundreads of items. At the bottom of my screen i've made my own page navigation bar with 2 buttons (prev and next) and a textView to show the page number. what i would like is to add the possibility to let the user see which page the user is on related to the total number of pages. i've managed to dynamically show/change the actual page number, but i dont know how to show the total number of pages.
the idea i have in mind is that i get the number of results from the xml. as u can see there are more that 2k records. i was thinking of making a method that does for example 2k/20=totalPages. where the 2k records change depending on what query is asked.
<elencoanagrafiche found="2542" errStatus="0">
is it a good idea? or does anyone have a better idea? does android have an api that does this automatically? thanks!!!
Upvotes: 0
Views: 595
Reputation: 4784
The way you propose to calculate the total pages is correct, eg:-
int records = 25;
int pageSize = 5;
int totalPages = (int) Math.ceil(records / pageSize);
I do not know of an out-of-the-box solution for list pagination in Android
Upvotes: 1