简单分页的实现

先上效果图 : 

在实际项目中 , 经常会用到分页 , 我实现的效果为每页显示10行数据 , 数据分别显示数据总数量 , 当前显示的页数 , 总页数 , 当只有一页的时候无法点击上一页与下一页的切换 , 话不多说 , 直接切入正题 :

第一步 , 首先创建分页的实体类 , 代码如下 :

public class Page {
	private int sum;//数据总条数
	private int current;//当前页数
	private int number;//每页显示条数
	private int sumPage;//总页数
	public int getSum() {
		return sum;
	}
	public void setSum(int sum) {
		this.sum = sum;
	}
	public int getCurrent() {
		return current;
	}
	public void setCurrent(int current) {
		if(current<1){
			this.current=1;
		}else if(current>sumPage){
			this.current = sumPage;
		}else{
			this.current = current;
		}
		
	}
	public int getNumber() {
		return number;
	}
	public void setNumber(int number) {
		if(number<=0){
			this.number=5;
		}
		this.number = number;
	}
	public void setSumPage() {
		int a=sum%number;
		if(a!=0){
			this.sumPage= sum/number+1;
		}else{
			this.sumPage= sum/number;
		}
	}
	public int getSumPage() {
		return this.sumPage;
	}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值