1, Android's own pull-down refresh Swiperefreshlayout

Source: Internet
Author: User

1 <Android.support.v4.widget.SwipeRefreshLayout2     xmlns:android= "Http://schemas.android.com/apk/res/android"3 Android:id= "@+id/swipe_container"4 Android:layout_width= "Match_parent"5 Android:layout_height= "Match_parent" >6     <ListView7         Android:id= "@+id/listview"8 Android:layout_width= "Match_parent"9 Android:layout_height= "Wrap_content"Ten android:padding= "16DP" /> One </Android.support.v4.widget.SwipeRefreshLayout
3 Importjava.util.ArrayList;4 Importandroid.app.Activity;5 ImportAndroid.os.Bundle;6 ImportAndroid.os.Handler;7 Importandroid.support.v4.widget.SwipeRefreshLayout;8 ImportAndroid.widget.ArrayAdapter;9 ImportAndroid.widget.ListView;Ten  One  Public classMainactivityextendsActivityImplements  A Swiperefreshlayout.onrefreshlistener { -  -     Privateswiperefreshlayout mswipelayout; the     PrivateListView Mlistview; -     Privatearraylist<string> list =NewArraylist<string>(); -  -     protected voidonCreate (Bundle savedinstancestate) { +         Super. OnCreate (savedinstancestate); - Setcontentview (r.layout.activity_main); +  AMlistview =(ListView) Findviewbyid (R.id.listview); atMlistview.setadapter (NewArrayadapter<string> ( This,  - Android. R.layout.simple_list_item_1, - getData ()) -         ); -  -Mswipelayout =(swiperefreshlayout) Findviewbyid (r.id.swipe_container); inMswipelayout.setonrefreshlistener ( This); -         //the random color of the turning circle to Mswipelayout.setcolorschemeresources (Android. R.color.holo_blue_bright, + Android. R.color.holo_green_light, Android. R.color.holo_orange_light, - Android. R.color.holo_red_light); the     } *  $     PrivateArraylist<string>GetData () {Panax NotoginsengList.add ("Hello"); -List.add ("This is Stormzhang"); theList.add ("An Android Developer"); +List.add ("Love Open Source"); AList.add ("My Github:stormzhang"); theList.add ("Weibo:googdev"); +         returnlist; -     } $  $      Public voidOnrefresh () { -         NewHandler (). postdelayed (NewRunnable () { - @Override the              Public voidrun () { -Mswipelayout.setrefreshing (false);Wuyi             } the}, 5000); -     } Wu}

1, Android's own drop-down refresh swiperefreshlayout

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.