Enable SwipeRefreshLayout in Android Support V4 to Support pulling and loading more.
Preface there was no pull-down refresh component in the original Android SDK, but this component is indeed a required component of most apps. Fortunately, google has a SwipeRefreshLayout In the v4 package, but this component only supports pull-down refresh and does not support pulling and loading more operations. Therefore, we can simply expand this component to achieve the goal of pulling and downloading.
The basic principle is that it is automatically loaded when it is pulled or rolled to the bottom by judging whether it has been rolled to the bottom of ListView or other views, and then triggering corresponding operations. Here we will describe the ListView. Therefore, we need to listen to the ListView rolling event. When the ListView is rolled to the bottom, the loading operation is automatically triggered. However, when the user supports sliding the screen by fingers and does not scroll, we also need to let it load, therefore, in this case, pull and load more data. Therefore, we need to make a judgment in the touch event. If we get to the bottom and the user is pulling up, we will execute more loading operations.