Don't say anything but the picture above
I'm using a third party that relies on PullToRefresh to do this
This is just a listening method.
First inject dependencies:
//Refresh pullToRefresh
compile 'com.jwenfeng.pulltorefresh:library:1.0.3'
Then layout:
<com.jwenfeng.library.pulltorefresh.PullToRefreshLayout
android:id="@+id/pullToRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
//Here you can define your requirements controls (for example, listView,GridView...)
//My list is recyclerView (if you need to inject dependencies to use recyclerView)
<android.support.v7.widget.RecyclerView
android:id="@+id/recView"
android:layout_width="match_parent"
android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>
</com.jwenfeng.library.pulltorefresh.PullToRefreshLayout>
Then initialize the control and set up the monitor in MainActivity
//Initialize/Find Control/Get Resource ID
PullToRefreshLayout ptr = (PullToRefreshLayout) findViewById(R.id.pullToRefresh);
//Set up listener setRefreshListener
//Then generate refresh and load overrides
ptr.setRefreshListener(new BaseRefreshListener() {
@Override
//Refresh Method
public void refresh() {
//Write your drop-down refresh business requirements logic here
if (list != null) {
initNet();
}
//Don't forget to turn off the refresh effect
ptr.finishRefresh();
}
@Override
//Load more methods
public void loadMore() {
//Write your home's business needs logic here
if (list != null) {
list.addAll(list.size(), list);
recAdapter.notifyDataSetChanged();
}
//Don't forget to turn off loading for more effects
ptr.finishLoadMore();
}
});
That's OK.
Emphasize a few points:
1 My Android studio is version 2.3.3, v7 for SDK.....26. +
2 For code simplicity, I didn't move the package, so you can guide it yourself
3If you access the network: Don't forget to add network permissions in AndroidManifest
<uses-permission android:name="android.permission.INTERNET"/>