Android drop-down refresh control usage

Source: Internet
Author: User

Activity_main.xml

<relativelayout xmlns:android="Http://schemas.android.com/apk/res/android"xmlns:tools="Http://schemas.android.com/tools"Android:layout_width="Match_parent"android:layout_height="Match_parent"tools:context="Com.example.xiala.MainActivity"> <android. Support. V4. Widgets. SwiperefreshlayoutXmlns:android="Http://schemas.android.com/apk/res/android"Android:id="@+id/swipe_container"Android:layout_width="Match_parent"android:layout_height="Match_parent"> <scrollview android:layout_width="Match_parent"android:layout_height="Match_parent"> <textview android:layout_width="Match_parent"android:layout_height="Wrap_content"android:layout_margintop="16DP"android:gravity="Center"android:text="@string/hello_world"/> </ScrollView> </android. Support. V4. Widgets. Swiperefreshlayout></RelativeLayout>

Mainactivity.java

ImportAndroid.os.Bundle;ImportAndroid.os.Handler;ImportAndroid.support.v4.widget.SwipeRefreshLayout;ImportAndroid.support.v4.widget.SwipeRefreshLayout.OnRefreshListener;Importandroid.support.v7.app.ActionBarActivity; Public  class mainactivity extends actionbaractivity  implements  Onrefreshlistener{    PrivateSwiperefreshlayout swipelayout;@Override    protected void onCreate(Bundle savedinstancestate) {Super. OnCreate (Savedinstancestate);        Setcontentview (R.layout.activity_main);        Swipelayout = (swiperefreshlayout) Findviewbyid (R.id.swipe_container); Swipelayout.setonrefreshlistener ( This); Swipelayout.setcolorscheme (Android. R.color.holo_blue_bright, Android. R.color.holo_green_light, Android. R.color.holo_orange_light, Android.    R.color.holo_red_light); } Public void Onrefresh() {NewHandler (). postdelayed (NewRunnable () {@Override  Public void Run() {swipelayout.setrefreshing (false); }        }, the); }}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android drop-down refresh control usage

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.