Swiperefreshlayout out already has a period of time, has changed two kinds of refresh effect, all under the V4 package, the new refresh effect is still very good, many apps have adopted this kind of refresh effect, I recently also on this side, in the research time found, The original swiperefreshlayout only support gesture dropdown to appear refresh effect, see "Jane book" Android client each time there is that kind of switch page automatically come out refresh effect, oneself also tried, directly set setrefreshing (True) This method can not see the effect of , so the source has been modified, not to say much, directly on the code
Public class autoswiperefreshlayout extends swiperefreshlayout { Public Autoswiperefreshlayout(Context context) {Super(context); } Public Autoswiperefreshlayout(context context, AttributeSet attrs) {Super(context, attrs); }/** * Automatic refresh * / Public void AutoRefresh() {Try{Field Mcircleview = SwipeRefreshLayout.class.getDeclaredField ("Mcircleview"); Mcircleview.setaccessible (true); View progress = (view) mcircleview.get ( This); Progress.setvisibility (VISIBLE); Method setrefreshing = SwipeRefreshLayout.class.getDeclaredMethod ("Setrefreshing",Boolean. class,Boolean. Class); Setrefreshing.setaccessible (true); Setrefreshing.invoke ( This,true,true); }Catch(Exception e) {E.printstacktrace (); } }}
The code looks relatively simple, it does take a lot of effort to read the source, in addition to adding a method that can be automatically refreshed, no modification of the other, the use is the same as ordinary swiperefreshlayout, It is only possible to call AutoRefresh () when the data is loaded for the first time to see the refresh effect, see:
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
A swiperefreshlayout that can be automatically displayed in the page refresh effect