Question

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.

Was it helpful?

Solution

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top