@@ -0,0 +1,2623 @@
+package com.marshalchen.common.usefulModule;%0A%0Aimport android.content.Context;%0Aimport android.util.AttributeSet;%0Aimport android.widget.AbsListView;%0Aimport android.widget.ListView;%0Aimport com.marshalchen.common.commonUtils.basicUtils.HandlerUtils;%0Aimport com.marshalchen.common.commonUtils.logUtils.Logs;%0A%0A/**%0A * Created by cym on 14-9-12.%0A */%0Apublic class LoadMoreListView extends ListView %7B%0A%0A    int currentFirstVisibleItem;%0A    int currentVisibleItemCount;%0A    int currentScrollState;%0A    int totalItemCounts;%0A    boolean isLoading = false;%0A%0A    public LoadMoreListView(Context context) %7B%0A        super(context);%0A        init();%0A    %7D%0A%0A    public LoadMoreListView(Context context, AttributeSet attrs) %7B%0A        super(context, attrs);%0A        init();%0A    %7D%0A%0A    public LoadMoreListView(Context context, AttributeSet attrs, int defStyle) %7B%0A        super(context, attrs, defStyle);%0A        init();%0A    %7D%0A%0A    private void isScrollCompleted() %7B%0A        Logs.d(%22totalItemCounts---%22 + totalItemCounts + %22    %22 + %22   %22 + currentFirstVisibleItem + %22   %22 + currentVisibleItemCount);%0A        if (this.currentVisibleItemCount %3E 0 && this.currentScrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE && (currentFirstVisibleItem + currentVisibleItemCount) %3E= totalItemCounts - 1) %7B%0A            /*** In this way I detect if there's been a scroll which has completed ***/%0A            /*** do the work for load more date! ***/%0A            Logs.d(%22more---%22);%0A            if (!isLoading) %7B%0A                isLoading = true;%0A                onLoadMore();%0A            %7D%0A        %7D%0A    %7D%0A%0A%0A    private void init() %7B%0A        setOnScrollListener(loadMoreOnScrollListener);%0A    %7D%0A%0A    OnScrollListener loadMoreOnScrollListener = new AbsListView.OnScrollListener() %7B%0A%0A%0A        @Override%0A        public void onScrollStateChanged(AbsListView view, int scrollState) %7B%0A            currentScrollState = scrollState;%0A            isScrollCompleted();%0A        %7D%0A%0A        @Override%0A        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) %7B%0A            currentFirstVisibleItem = firstVisibleItem;%0A            currentVisibleItemCount = visibleItemCount;%0A            totalItemCounts = totalItemCount;%0A        %7D%0A    %7D;%0A    private OnLoadMoreListener onLoadMoreListener;%0A%0A    public interface OnLoadMoreListener %7B%0A%0A        public void loadMore();%0A    %7D%0A%0A    public void setOnLoadMoreListener(OnLoadMoreListener onLoadMoreListener) %7B%0A        this.onLoadMoreListener = onLoadMoreListener;%0A    %7D%0A%0A    public void onLoadMore() %7B%0A        onLoadMoreListener.loadMore();%0A        isLoading = false;%0A    %7D%0A%7D%0A

add LoadMoreListView