fromIndex和toIndex的計算問題
//起始索引(列表中的數據從0開始)
int fromIndex = (this.paperCurrent-1)*this.paperSize;
//結束索引
int toIndex;
if(this.paperCurrent*this.paperCurrent>this.totalRecord){
toIndex = this.totalRecord;
}else{
toIndex = this.paperCurrent*this.paperSize;
}
起始列表應該是從0開始的吧,如果有10條記錄的話,應該是0-9做為索引,如果每頁5條,那么2*5=10,是否需要在計算結束索引時-1呢?求告知
2016-09-09
如果是 paperCurrent是2? pageSize是5 ? 這個fromIndex剛好是第二頁的第一個 5? 你代數算一下!
2016-09-09
paperCurrent 最小是1?? fromIndex不會取值負數!