How to make a Button Visible/Gone on scroll listener of gridView in Android

可紊 提交于 2019-12-06 14:03:09

you can do this by using setOnScrollListener for GridView as:

gridview.setOnScrollListener(new OnScrollListener() {

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

      }

    @Override
    public void onScrollStateChanged(AbsListView view, int scrollState) {
            // TODO Auto-generated method stub
      switch(scrollState) {
        case 2: // SCROLL_STATE_FLING 
        //hide button here
        break;

        case 1: // SCROLL_STATE_TOUCH_SCROLL 
        //hide button here
        break;

        case 0: // SCROLL_STATE_IDLE 
        //show button here
        break;

            default:
             //show button here
        break;
           }
        }
     });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!