分页中数字页码前五后四的实现

 


public int[] getBeginAndEnd() { 
	int[] pagelen=new int[2];
	int begin = 1;
	int end = totalPage;
	if((end - begin) <= 9){
		//显示十个页码,不足十个不做处理
	}else{
		if((currentPage - begin) >= 5){
			if((currentPage+4) >= totalPage){
				end = totalPage;
				begin = end - 9;
			}else{
				end = currentPage + 4;
				begin = currentPage -5;
			}
		}else{
			if((currentPage -5) >= 1){
				begin = currentPage - 5;
				end = begin + 9;
			}else{
				begin = 1;
				end=begin + 9;
			}
		}
	}
	pagelen[0] = begin;
	pagelen[1] = end;
	return pagelen;
}


你可能感兴趣的:(前五后四分页)