ExpandableListView最后一组在屏幕事件中可见的最后一个孩子?

时间:2016-01-19 09:50:59

标签: android scroll expandablelistadapter

我怎样才能获得标题中写的事件?我想知道屏幕上是否显示RawLastChild

我怎样才能抓住事件?

2 个答案:

答案 0 :(得分:0)

您可以将此代码用于expandablelistview以查看最后一个元素

mExpandableListView.setOnScrollListener(new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {

            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount
                    , int totalItemCount) {
                if(firstVisibleItem+visibleItemCount>=totalItemCount){
                    //the last item is visible
                }

            }
        });

答案 1 :(得分:0)

以下代码段将解决您的问题。测试和工作正常!

expandableListView.setOnScrollListener(new AbsListView.OnScrollListener() {
        @TargetApi(Build.VERSION_CODES.KITKAT)
        @Override
        public void onScrollStateChanged(AbsListView absListView, int scrollState) {
            if (!absListView.canScrollList(View.SCROLL_AXIS_VERTICAL) && scrollState == SCROLL_STATE_IDLE) {
                //When List reaches bottom
                loadMoreData();
            }
        }

        @Override
        public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

        }
    });
}