android ListView 做下拉刷新 下拉跳到第一项怎么解决
2个回答
展开全部
listView.setonRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { Log.e(TAG, "---下拉刷新---"); new AsyncTask() { protected Void doInBackground(Void... params) { try { mylineslistlist.clear(); mylinesorderlist.clear(); list.clear(); getMylines(0); } catch (Exception e) { e.printStackTrace(); } return null; } protected void onPostExecute(Void result) { adapter.notifyDataSetChanged(); listView.onRefreshComplete(); } }.execute(); } }); listView.setOnScrollListener(new OnScrollListener() { @Override public void onScrollStateChanged(final AbsListView view, int scrollState) { listView.onScrollStateChanged(view, scrollState); // 数据为空--不用继续下面代码了 if (list.size() == 0) return; // 判断是否滚动到底部 boolean scrollEnd = false; try { if (view.getPositionForView(loadingLayout) == view .getLastVisiblePosition()) scrollEnd = true; } catch (Exception e) { scrollEnd = false; } if (scrollEnd) { // 如果是自动加载,可以在这里放置异步加载数据的代码 Log.e("LOADMORE", "loading..."); if (currentPage < pageNum) { // Log.e(TAG, "---currentPage is " + currentPage); currentPage++; // Log.e(TAG, "---currentPage is " + currentPage); handler.postDelayed(new Runnable() { @Override public void run() { // Log.d(TAG, "---loadData page is" + // currentPage); getMylines(currentPage); // listView.setSelection(view
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
listView.setonRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { Log.e(TAG, "---下拉刷新---"); new AsyncTask() { protected Void doInBackground(Void... params) { try { mylineslistlist.clear(); mylinesorderlist.clear(); list.clear(); getMylines(0); } catch (Exception e) { e.printStackTrace(); } return null; } protected void onPostExecute(Void result) { adapter.notifyDataSetChanged(); listView.onRefreshComplete(); } }.execute(); } }); listView.setOnScrollListener(new OnScrollListener() { @Override public void onScrollStateChanged(final AbsListView view, int scrollState) { listView.onScrollStateChanged(view, scrollState); // 数据为空--不用继续下面代码了 if (list.size() == 0) return; // 判断是否滚动到底部 boolean scrollEnd = false; try { if (view.getPositionForView(loadingLayout) == view .getLastVisiblePosition()) scrollEnd = true; } catch (Exception e) { scrollEnd = false; } if (scrollEnd) { // 如果是自动加载,可以在这里放置异步加载数据的代码 Log.e("LOADMORE", "loading..."); if (currentPage < pageNum) { // Log.e(TAG, "---currentPage is " + currentPage); currentPage++; // Log.e(TAG, "---currentPage is " + currentPage); handler.postDelayed(new Runnable() { @Override public void run() { // Log.d(TAG, "---loadData page is" + // currentPage); getMylines(currentPage); // listView.setSelection(view
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询