문제

Is there such a library which does that, or a group of libraries I could merge together to implement this feature?

I've found CW's EndlessAdapter and HorizontalVariableListView, which are answers to my requirements separately.

There seem to be compatibility issues between the two. Is it possible to have these features together? Please suggest.

도움이 되었습니까?

해결책

I used sephiroth74's Horizontal ListView.

For the Endless ListView, I put a ProgressBar in its footer. This is the code for the Endless ListView.

private enum ListViewStatus {
    LOADING_NEXT_PAGE, DOING_NOTHING
}

private void setEndlessListView(HListView hListView, final Data listData) {
    View footer = View.inflate(getContext(), R.layout.endless_list_footer, null);
    footer.setLayoutParams(new AbsHListView.LayoutParams(AbsHListView.LayoutParams.WRAP_CONTENT, mDimensionsFeaturedThumbnail.y));
    hListView.addFooterView(footer);

    hListView.setOnScrollListener(new OnScrollListener() {
        private int mFirstVisibleItem;
        @Override
        public void onScrollStateChanged(AbsHListView view, int scrollState) {
        }
        @Override
        public void onScroll(AbsHListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            if(visibleItemCount != 0 && firstVisibleItem > mFirstVisibleItem) {
                boolean shouldLoadMore = (firstVisibleItem + visibleItemCount >= totalItemCount) && (mListView.getTag() == ListViewStatus.DOING_NOTHING);
                if(shouldLoadMore) {
                    loadMoreData(listData.getPageNumber()+1);
                }
            }
            mFirstVisibleItem = firstVisibleItem;
        }
    });
}

Don't forget to write this line upon initializing the ListView and loading the data:

mListView.setTag(ListViewStatus.DOING_NOTHING);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top