Android - ListView sliding the loading page data setting Scroll

Android - ListView fell Loading new data


Problems encountered, slipped past the loading function is poor, do not know why.

I tried for a long time and finally try out.

Think this approach more in line with the feeling of the user experience,

I will not feel the visual feeling beating, but a very loaded straight, very smooth.

Here is what I set onScrollListener

private OnScrollListener scrollListener = new OnScrollListener() {
		@Override
		public void onScroll(AbsListView view, int firstItem, int visible, int total) {
			scrollCount = visible + firstItem;
		}

		// 0.停止卷动  1.卷动中
		@Override
		public void onScrollStateChanged(AbsListView view, int scrollState) {
			if( scrollState == SCROLL_STATE_IDLE ) {
				mPosition = view.getFirstVisiblePosition();
				View v = view.getChildAt(0);
				mTop = (v == null) ? 0 : v.getTop();

				if( scrollCount >= perPage * page && pageCount >= page) {
					page++;
					loadNextPage();
				}
			}
		}
	};

Other load, the better the fishing data, the following re-set position

listView.setSelectionFromTop(mPosition, mTop);

Original: Big Box  Android - ListView loaded sliding Scroll down the page data set


Guess you like

Origin www.cnblogs.com/chinatrump/p/11516465.html