同様のグーグルページング技術



Similar Google Paging Technology



Imitation Baidu,GoogleInquirePaging technology analysis

Tab (the pagination) an automatic paging mechanism, can move the contents of the Web Form into smaller bundle of pages for presentation to suit a particular device. This mechanism also presents a user interface element can be used to browse to another page in the whole page is a web development application of knowledge will be. You should be familiar with and use.

In actual application development, the paging obvious is particularly important now baidu, google query paginated pages and pagination effect as follows: 1, Baidu search pagination observed effect is as follows: 2, Google search results page to achieve the following: Analysis process structure:
Page displayed page current page last page analysis
1 2 3 4 5 6 7 8 9 10 Next Page 1 10 10=1+9
Analysis 1: when the total number of pages is less than 11, Page index start value = 1 The final value of the index page = total number of pages
Previous 1234567891011 Next 2 11 11=2+9
Previous 1 2 3 9 10 11 12 ... ... Next 3 12 12=3+9
Previous 1 2 3 ... ... 10 11 12 13 Next 4 13 13=4+9
Previous 1 2 3 ... ... 11 12 13 14 Next 5 14 14=5+9
Previous 1 2 3 ... ... 12 13 14 15 Next 6 15 15=6+9
Previous 1 2 3 ... ... 13 14 15 16 Next 7 16 16=7+9
Previous 123 ... 16171820 ... Next 11 20 20=11+9
Observe
Previous 234 ... 18292021 ... Next 12 21 2=12-10 21=12+9
Previous 3 4 5 19 20 21 22 ... ... Next 13 22 3=13-10 22=13+9
Previous 4 5 6 20 21 22 23 ... ... Next 14 23 4=14-10 23=13+9
Analysis: When Greater than the total number of pages 11Displayed on the page of 20 pages in total, of which more than Observe that: Page Index this page starting value = -10 The final value of the index page = current page +9 Note: When the page When the final value of the index is greater than the total number of pages query, Then the effect should be as follows: The final value of the total number of pages indexed page = query Page = total number of pages indexed starting value queries -19
We did a simple analysis and algorithms that you can implement in Java code? Using java to achieve the following:
package cn.csdn.util import java.util.List /** * * @author redarmy_chen * * @param */ public class Pagination { // pagination information private int nowpage // this page private int countrecord // total record private int countpage // total number of pages public static final int PAGESIZE = 5 // number of records per page private int startpage // page Home private int endpage // End page page private final int SHOWPAGE = 6 // total number of pages of the page displayed baidu, google shows the total number of pages 20 // In the tests we use to test 6 private List allentities private String url / ** based on the current page and the total number of records to construct the target page * / public Pagination(int nowpage, int countrecord) { this.nowpage = nowpage this.countrecord = countrecord / ** * Calculate the total number of pages / this.countpage = this.countrecord % this.PAGESIZE == 0 ? this.countrecord / this.PAGESIZE : this.countrecord / this.PAGESIZE + 1 / ** Calculated value startpage and endpage * / / ** Total number of pages is less than 4 * / if (this.countpage <(this.SHOWPAGE / 2 + 1)) { this.startpage = 1 // start page is page 1 this.endpage = this.countpage // page to the last page is the total number of pages } else { / ** else the total number of pages is larger than 4 * / / ** First, the current value of the page is less than equal to 4 * / if (this.nowpage = this.countpage) { this.endpage = this.countpage } } else { this.startpage = this.nowpage - 3 this.endpage = this.nowpage + 2 if (this.endpage>= this.countpage) { this.endpage = this.countpage if (this.countpage


上記の返品redarmy_chenのオリジナル、著作権redarmy_chenはすべて、質問を自由に転載することはできません。root@ xxxxxにメールを送信してください。