Android swiperefreshlayout dropdown Refresh Source Resolution _android

Source: Internet
Author: User

The example of this article for everyone to share the Swiperefreshlayout refresh source, for your reference, the specific content as follows

1.SwipeRefreshLayout is Google's support V4 19.1 version of the library update of a drop-down refresh component, to achieve a more convenient refresh.

disadvantage : Only the dropdown

Sets the color Swipe_refresh_layout.setcolorschemeresources (Android) for refreshing control loops
. R.color.holo_blue_light, Android. R.color.holo_orange_light, Android. R.color.holo_red_light, Android. R.color.holo_green_light);
Sets the refresh control background color
Swipe_refresh_layout.setprogressbackgroundcolorschemecolor (getresources (). GetColor (Android). R.color.white));
Set sliding distance
Swipe_refresh_layout.setdistancetotriggersync (m);
Set the size mode
swipe_refresh_layout.setsize (swiperefreshlayout.default);
Sets the Drop-down refresh control state Hide
swipe_refresh_layout.setrefreshing (false);

2. Refer to the Android.support.v4.widget.SwipeRefreshLayout control in the XML file, where you can place any control, such as Listview,gridview.

<relativelayout 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/id_swipe_ly" 
  android:layout_width= "match_parent" 
  android:layout_height= "Match_parent" > 
 
  <listview 
   android:id= "@+id/id_listview" 
   android:layout_width= "Match_parent" 
   android: layout_height= "Match_parent" > 
  </ListView> 
 </android.support.v4.widget.swiperefreshlayout > 
 

3.Java Code

public class Mainactivity extends activity implements Swiperefreshlayout.onrefreshlistener {private swiperefreshlayou
 T swipelayout;
 Private ListView ListView;
 Private Listviewadapter adapter;
  
 Private list<iteminfo> infolist;
  @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);
 
  Setcontentview (R.layout.activity_main);
  Swipelayout = (swiperefreshlayout) This.findviewbyid (R.id.swipe_refresh);
   
  Swipelayout.setonrefreshlistener (this); Top-refreshed style Swipelayout.setcolorscheme (Android). R.color.holo_red_light, Android. R.color.holo_green_light, Android. R.color.holo_blue_bright, Android.
 
  R.color.holo_orange_light);
  Infolist = new arraylist<iteminfo> ();
  ItemInfo info = new ItemInfo ();
  Info.setname ("Coin");
  Infolist.add (info);
  ListView = (ListView) This.findviewbyid (R.id.listview);
  adapter = new Listviewadapter (this, infolist);
 Listview.setadapter (adapter); public void Onrefresh () {New HaNdler (). postdelayed (New Runnable () {public void run () {swipelayout.setrefreshing (false);
    ItemInfo info = new ItemInfo ();
    Info.setname ("Coin-refresh");
    Infolist.add (info);
   Adapter.notifydatasetchanged ();
 }, 500); }
}

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.