Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android studio 项目列表结束时停止滚动_Android Studio_Android Recyclerview_Scroll_Android Adapter - Fatal编程技术网

Android studio 项目列表结束时停止滚动

Android studio 项目列表结束时停止滚动,android-studio,android-recyclerview,scroll,android-adapter,Android Studio,Android Recyclerview,Scroll,Android Adapter,我想在RecyclerView中达到结束时停止滚动。。目前,当我向下滚动新帖子时,我可以无限制地滚动,有时我会跳过第二页并加载第三页 看看这个: 这是我的滚动列表: recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) {

我想在RecyclerView中达到结束时停止滚动。。目前,当我向下滚动新帖子时,我可以无限制地滚动,有时我会跳过第二页并加载第三页

看看这个:

这是我的滚动列表:

  recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            if (dy > 0) { //check for scroll down
                visibleItemCount = mLayoutManager.getChildCount();
                totalItemCount = mLayoutManager.getItemCount();
                pastVisiblesItems = mLayoutManager.findFirstVisibleItemPosition();

                if ((visibleItemCount + pastVisiblesItems) >= totalItemCount) {

                    Log.d("tisha==>>","Is loading = "+loading);
                    // Do pagination.. i.e. fetch new data

                    if (!loading){

                        adapter.showHideProgress(true);
                        loading = true;

                        yourURL = "https://punjabidharti.com/wp-json/wp/v2/posts/?categories=4514&page=" + pageNo++;

                        getRetrofit();

                    }
                }
            }
        }
    });
在适配器中:

 public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
    mContext = parent.getContext();
    if (viewType == viewTypeData){
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.post_list,parent,false);
        return new MyDataHolder(view);
    }else {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_loading,parent,false);
        return new MyProgressHolder(view);
    }
}