Android new SwipeRefreshLayout control tutorial
SwipeRefreshLayout is a Google-style refresh control implemented by google after the PullToRefresh-ListView and ActionBarPullToRefresh, which features a strong google flavor.
After migrating to Android studio, you must use AppCompat_v7 21 +. After switching, you will find some interesting changes. For example, this SwipeRefreshLayout will evolve into a circle.
Let's take a look at how to use SwipeRefreshLayout! <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + pc9wpgokytfpyndo0qru2rk8vtba78pmyfnd96o6cjxwp1_vcd4kpha + PHByZSBjbGFzcz0 = "brush: java;">
Then you need to initialize the control in the code
swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_purple, android.R.color.holo_blue_bright, android.R.color.holo_orange_light, android.R.color.holo_red_light); swipeRefreshLayout.setOnRefreshListener(this);
Here, the circle sets several colors to replace the display, and then sets the listener to implement the onRefresh method of implements SwipeRefreshLayout. OnRefreshListener interface.
@Override public void onRefresh() { adapter.sync(); }
In this way, the SwipeRefreshLayout control can be displayed in the drop-down list. However, the actual requirement is generally to load network requests, which is also very simple. SwipeRefreshLayout during the start request. setRefreshing (true); Call swipeRefreshLayout when the request is complete. setRefreshing (false );
So much? Yes, it's easy. You no longer have to endure the three dependency packages of ActionBarPullToRefresh and the compatibility issues in AppCompat_v7 21.
Let's talk about another question,
android.support.v4.widget.SwipeRefreshLayout
You do not need to use it in the heel layout, but there must be only one internal control, and you can slide it, such as listview and Scrollview. If a slide exception occurs, refer to the following link:
Https://yassirh.com/2014/05/how-to-use-swiperefreshlayout-the-right-way/
Slide Problem