Swiperefreshlayout official drop-down refresh component in Android v4 package

Source: Internet
Author: User

Swiperefreshlayout in the V4 package, corresponding V4demo also have a corresponding example. If not, please download the latest SUPPORT-V4

Swiperefreshlayout can have only one direct child view, which may be a ListView or a layout or other component that needs to be refreshed.

The Setonrefreshlistener is used to listen for refreshed actions. Swiperefreshlayout pull down, there will be a refresh effect out, triggering the listener.

If you need a refreshed animation,setrefreshing (True), stop: Setrefreshing (false)

If you want to disable refresh animations and gesture responses,ssetenable (false), restore Setenable (True)

Here's an example of a V4:

public class Swiperefreshlayoutactivity extends Activity implements Onrefreshlistener {public static final string[] TI            TLEs = {"Henry IV (1)", "Henry V", "Henry VIII", "Richard II",            "Richard III", "Merchant of Venice", "Othello", "King Lear", "Henry IV (1)", "Henry V", "Henry VIII", "Richard II", "Richard III", "Merchant of V" Enice "," Othello "," King Lear "," Henry IV (1) "," Henry V "," Henry V "            III "," Richard II "," Richard III "," Merchant of Venice "," Othello ",            "King Lear", "Henry IV (1)", "Henry V", "Henry VIII", "Richard II",    "Richard III", "Merchant of Venice", "Othello", "King Lear"}; Try a SUPER quick refresh to make sureWe don ' t get extra refreshes//While the user's finger is still down.    Private static Final Boolean Super_quick_refresh = false;    Private View mcontent;    Private Swiperefreshlayout Mswiperefreshwidget;    Private ListView mlist;    Private Handler Mhandler = new Handler (); Private final Runnable Mrefreshdone = new Runnable () {@Override public void run () {Mswiperefres        Hwidget.setrefreshing (FALSE);    }    };        @Override public void OnCreate (bundle bundle) {super.oncreate (bundle);        Setcontentview (r.layout.swipe_refresh_widget_sample);        Mswiperefreshwidget = (swiperefreshlayout) Findviewbyid (r.id.swipe_refresh_widget);        Mswiperefreshwidget.setcolorscheme (R.color.color1, R.color.color2, R.color.color3, R.color.color4);        Mlist = (ListView) Findviewbyid (r.id.content); arrayadapter<string> arrayadapter = new Arrayadapter<string> (this, Android. R.layout.simple_list_iteM_1, Android.        R.id.text1, TITLES);        Mlist.setadapter (Arrayadapter);        Mswiperefreshwidget.setonrefreshlistener (this);    Mswiperefreshwidget.setprogressviewendtarget (False, 8);    } @Override public void Onrefresh () {refresh ();        } @Override Public boolean Oncreateoptionsmenu (Menu menu) {menuinflater inflater = Getmenuinflater ();        Inflater.inflate (R.menu.swipe_refresh_menu, menu);    return true;     }/** * Click handler for the menu item to force a refresh.        */@Override public boolean onoptionsitemselected (MenuItem item) {final int id = item.getitemid ();                Switch (ID) {case r.id.force_refresh:mswiperefreshwidget.setrefreshing (true);                Refresh ();        return true;    } return false;        } private void Refresh () {mhandler.removecallbacks (mrefreshdone);    Mhandler.postdelayed (Mrefreshdone, 1000); }}


<android.support.v4.widget.swiperefreshlayout xmlns:android= "Http://schemas.android.com/apk/res/android"    android:id= "@+id/swipe_refresh_widget"    android:layout_width= "match_parent"    android:layout_height= "Match_parent" >    <!--Some full screens pullable view that'll be the offsetable content--    <listview        android:id= "@+id/content"        android:layout_width= "match_parent"        android:layout_height= "match_parent "/></android.support.v4.widget.swiperefreshlayout>

Swiperefreshlayout official drop-down refresh component in Android v4 package

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.