Items inside GridView getting repeated when screen scrolls

前端 未结 5 906
日久生厌
日久生厌 2020-12-02 10:41

I\'m using a GridView to show a set of Categories that user can chose. Each item of the grid is consisted by an ImageView and a TextView, both retrieved from server. When an

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-02 11:26

    Send and gridview or listview and In constructor implement this method implement onscroll listener

        this.mGridView = mGridView;
        this.mGridView.setOnScrollListener(new OnScrollListener() {
    
            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {
                Log.v("onScrollStateChanged", "onScrollStateChanged");
                if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
                    isScrollStop = true;
    
                    notifyDataSetChanged();
                } else {
                    isScrollStop = false;
                }
            }
    
            @Override
            public void onScroll(AbsListView view, int firstVisibleItem,
                    int visibleItemCount, int totalItemCount) {
                Log.v("onScroll", "onScroll");
            }
        });
    

提交回复
热议问题