zoukankan      html  css  js  c++  java
  • 翻页工具类

    简洁明了,一直在用的一个翻页类.  本地数据翻页的话,能够使用.

    效果:

    界面非常easy,不再浪费感情.

    源代码例如以下:

    /**
     * 
    * @Title: Page.java
    * @Package fay.frame.tools
    * @Description: 翻页工具
    * @author : Fay
    * @date 2014-6-27 下午3:14:31
    * @version V1.0
     */
    public class Page {
    int total = 100;
    int curPage = 1;
    int maxPage = 0;
    int perPageNum = 10;
    int startIndex = 0;
    int endIndex = 0;
    
    
    public void setTotal(int total) {
    this.total = total;
    }
    
    
    public void setPerPageNum(int perPageNum) {
    this.perPageNum = perPageNum;
    }
    
    
    public Page() {
    
    
    }
    
    
    public Page(int _total, int _perPageNum) {
    total = _total;
    perPageNum = _perPageNum;
    if (total % perPageNum == 0) {
    maxPage = total / perPageNum;
    } else {
    maxPage = total / perPageNum + 1;
    }
    }
    
    
    public void toPage(int index) {
    if (index < 1) {
    index = 1;
    } else if (index > maxPage) {
    index = maxPage;
    }
    curPage = index;
    startIndex = (curPage - 1) * perPageNum + 1;
    endIndex = startIndex + perPageNum - 1;
    if (endIndex > total) {
    endIndex = total;
    startIndex = endIndex - perPageNum + 1;
    }
    }
    
    
    public void prePage() {
    toPage(curPage--);
    }
    
    
    public void nextPage() {
    toPage(curPage++);
    }
    }


  • 相关阅读:
    Hdu 5073 Galaxy 精度问题
    HDU 4435 charge-station (并查集)
    HDU-4689 Derangement
    HDU 1011 Starship Troopers
    python 冒泡、快速、归并排序
    Django 上下文管理器的应用
    Django ajax小例
    Django 上传文件
    Django 登录验证码
    Django 模型中的CRUD
  • 原文地址:https://www.cnblogs.com/yjbjingcha/p/7403011.html
Copyright © 2011-2022 走看看