滚动到列表视图底部时值是否增加?

时间:2016-09-15 08:54:51

标签: android listview networking

我有一个listview,当我滚动到listview的底部时,用户可以看到进度条并在该请求中发送服务器请求我发送计数值,但问题是当我快速滚动底部向上时此计数值将每次我滚动底部之前递增,然后从服务器发送另一个请求到服务器的响应。

@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE && bBottomOfView) {
        Log.i("Listview", "scrolling stopped...");
        if (NetworkUtil.isConnected(getActivity())) {
            sz_RecordCount = String.valueOf(m_n_DefaultRecordCount);// convert int value to string
            sz_LastCount = String.valueOf(CLastCountData.getInstance().getS_szLastCount());// convert int value to string /////

            Log.e(TAG, "Last Count::" + sz_LastCount);
            Log.e(TAG, "Record count::" + sz_RecordCount);

            loadmoreData();


        } else {
            CSnackBar.getInstance().showSnackBarError(m_MainLayout, "No internet connection available", getActivity());
            m_ListView.removeFooterView(mFooter);
        }

    }
}

@SuppressLint("InflateParams")
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

    bBottomOfView = (firstVisibleItem + visibleItemCount) == totalItemCount;
    if (m_ListView.getFooterViewsCount() == 0) {
        mFooter = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.footer, null, false);
        m_ListView.addFooterView(mFooter);

    }

}

0 个答案:

没有答案