zoukankan      html  css  js  c++  java
  • 分页

    //计算分页
    	private void getPage(){
    		//计算总页数
    		if (getRowCount() % getNumber() == 0) {
    			setPageCount(getRowCount() / getNumber());
    		} else {
    			setPageCount(getRowCount() / getNumber() + 1);
    		}
    		//计算起始坐标
    		setFrom((getCurrentPage()-1)*getNumber());
    		
    		int indexSum = 6;//索引的sum值
    		int startIndex = 0;
    		int endIndex = 0;
    		
    		//计算出索引的位置 
    		if (getPageCount() > indexSum) {
    			if (getCurrentPage() > indexSum/2) {	//如果当前页大于分割数量的一半就开始分页
    				//最后几页的算法
    				if (getCurrentPage() >= (getPageCount() - indexSum)) {	//如果当前页大于等于总页数减去分割数量的一半
    					if(getCurrentPage() == getPageCount()){		//如果当前页等于总页数不在往后加页数
    						endIndex = (((getCurrentPage() - indexSum/2) + indexSum) - indexSum/2);
    					}else{
    						endIndex = (((getCurrentPage() - indexSum/2) + indexSum) - indexSum/2 + 2);
    					}
    				}else{
    					endIndex = ((getCurrentPage() - indexSum/2) + indexSum);
    				}
    				
    				if(endIndex>getPageCount()){
    					endIndex = getPageCount();
    				}
    				startIndex = endIndex - indexSum + 1;
    				
    			}else{
    				startIndex = 1;
    				endIndex = indexSum;
    			}
    		}else{//原始的那种分页
    			startIndex = 1;
    			endIndex = getPageCount();
    		}
            
            for (int i = startIndex; i <= endIndex; i++) {
    			paginList.add(i);
    		}
    	}
    

      

  • 相关阅读:
    python2的比较函数,cmp
    快速排序
    如果a,b,c为自然数,a+b+c=1000,a方+b方=c方,求出abc可能的组合(python实现)
    python之join
    python之functools partial
    Python 3 iter函数用法简述
    python线程之condition
    python 线程 event
    getattr getattribute setattr hasattr delattr
    Properties类
  • 原文地址:https://www.cnblogs.com/suncan0/p/5378402.html
Copyright © 2011-2022 走看看