user3662974
user3662974

Reputation: 85

how to check scroll bottom and top

bellow source code is not perfect code.

work to one side, work to only bottom side.

how to edit?

please give me edit example.

list.setOnScrollListener(new OnScrollListener() {

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

        }

        int mPosition=0;
        int mOffset=0;

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
             // TODO Auto-generated method stub
                int position = list.getFirstVisiblePosition();
                View v = list.getChildAt(0);
                int offset = (v == null) ? 0 : v.getTop();

                 if (mPosition < position || (mPosition == position && mOffset < offset)){
                      // Scrolled up 

                 } else {
                      // Scrolled down

                }
        }
     }); 

Upvotes: 0

Views: 223

Answers (1)

Ashish Garg
Ashish Garg

Reputation: 160

Have you try scrollView.fullScroll(ScrollView.FOCUS_UP); and scrollView.fullScroll(ScrollView.FOCUS_DOWN);

Upvotes: 1

Related Questions