Swiperefreshlayout is the official Google drop-down refresh control, the version below 4.0 needs to use the Android-support-v4.jar package to use
Android-support-v4.jar Bag: http://download.csdn.net/detail/h7870181/7784247
Official website API Address: https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html
GitHub Demo:https://github.com/stormzhang/swiperefreshlayoutdemo
Swiperefreshlayout is very simple to use, just add them to the outer layers of the controls that can be slid, such as: WebView, ListView, and Scroolview.
<?xml version= "1.0" encoding= "Utf-8"? ><framelayout xmlns:android= "http://schemas.android.com/apk/res/ Android " android:layout_width=" match_parent " android:layout_height=" match_parent "> < Android.support.v4.widget.SwipeRefreshLayout android:id= "@+id/swipe_container" android:layout_width= " Match_parent " android:layout_height=" match_parent "> <webview android:id=" @+id/webview " Android:layout_width= "Match_parent" android:layout_height= "match_parent"/> </ Android.support.v4.widget.swiperefreshlayout></framelayout>
Common methods:
void Setonrefreshlistener (Swiperefreshlayout.onrefreshlistener listener) Set Refresh Listener
void setcolorschemecolors (int color1, int color2, int color3, int color4) set Four color progress bar styles
void Setrefreshing (Boolean refreshing) hides or displays a progress bar
Boolean isrefreshing () determines whether the progress bar is displayed
Combined with WebView use is also very simple, you can implement some functions, drop-down refresh the current page, click on the page in the current page to browse and display the Swiperefreshlayout progress bar, overall is good
public class Fragment5 extends Fragment {private View view;public WebView webview;private swiperefreshlayout swipelayout; @Overridepublic View Oncreateview (Layoutinflater inflater, ViewGroup container,bundle savedinstancestate) {view = Inflater.inflate (R.LAYOUT.ACTIVITY_FRAGMENT5, null); swipelayout = (swiperefreshlayout) View.findviewbyid ( R.id.swipe_container); Swipelayout.setonrefreshlistener (new Swiperefreshlayout.onrefreshlistener () {@ overridepublic void Onrefresh () {//Re-refresh page Webview.loadurl (Webview.geturl ());}); Swipelayout.setcolorscheme (R.color.holo_blue_bright,r.color.holo_green_light, R.color.holo_orange_light, R.color.holo_red_light) WebView = (WebView) View.findviewbyid (R.id.webview); Webview.loadurl ("Http://blog.csdn.net /h7870181 ");//Add JavaScript support Webview.getsettings (). Setjavascriptenabled (True); Cancels the scrollbar Webview.setscrollbarstyle (webview.scrollbars_outside_overlay);//Touch Focus works Webview.requestfocus ();// Click on the link to continue responding to webview.setwebviewclient in the current browser (new Webviewclient () {@Overridepublic BooLean shouldoverrideurlloading (WebView view, String URL) {view.loadurl (URL); return true; }});//Set Progress bar webview.setwebchromeclient (new Webchromeclient () {@Overridepublic void onprogresschanged (WebView view, int newprogress) {if (newprogress = = 100) {//Hide progress bar swipelayout.setrefreshing (false); } else {if (!swipelayout.isrefreshing ()) swipelayout.setrefreshing (true); }super.onprogresschanged (view, newprogress);}); return view;}}
Almost forgot to post the color.xml resource file, I have a ah!
<?xml version= "1.0" encoding= "Utf-8"?><resources> <!--A light holo Shade of blue--<color NA Me= "Holo_blue_light" > #ff33b5e5 </color> <!--A light holo shade of green and <color name= "Holo_gree N_light "> #ff99cc00 </color> <!--A light holo Shade of red--<color name=" Holo_red_light "> #fff f4444</color> <!--A dark holo Shade of blue, <color name= "Holo_blue_dark" > #ff0099cc </color& Gt <!--a dark holo shade of green and <color name= "Holo_green_dark" > #ff669900 </color> <!--A Dark Holo Shade of red--and <color name= "Holo_red_dark" > #ffcc0000 </color> <!--A holo shade of purple- -<color name= "Holo_purple" > #ffaa66cc </color> <!--A light holo Shade of orange---<col or name= "Holo_orange_light" > #ffffbb33 </color> <!--A dark holo Shade of orange--and <color name= "ho Lo_orange_dark "≫ #ffff8800 </color> <!--A really bright holo shade of blue and <color name= "Holo_blue_bright" > #ff 00ddff</color></resources>
Not much technical content, purely accumulation of learning, but also hope you forgive me!
success stems from continuous learning and accumulation!