SwipeRefreshLayout实现下拉刷新(简洁)

来源:互联网 发布:淘宝魔镜免费版 编辑:程序博客网 时间:2024/05/16 23:36

布局文件:

[html] view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2.   
  3. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  4.                 android:layout_width="match_parent"  
  5.                 android:layout_height="match_parent">  
  6.   
  7.     <android.support.v4.widget.SwipeRefreshLayout  
  8.         android:id="@+id/srl_refresh"  
  9.         android:layout_above="@id/rl_send"  
  10.         style="@style/Rosemary.Plane">  
  11.   
  12.         <ScrollView  
  13.             android:id="@+id/sl_part"  
  14.             style="@style/BaseStyle.ScrollView">  
  15.   
  16.             <RelativeLayout  
  17.                 android:paddingBottom="@dimen/margin_standard"  
  18.                 android:layout_width="match_parent"  
  19.                 android:layout_height="match_parent">  
  20.   
  21.                 <!--订单信息-->  
  22.                 <RelativeLayout  
  23.                     android:id="@+id/part_top"  
  24.                     style="@style/BaseStyle.FullWrap"  
  25.                     android:layout_alignParentTop="true"  
  26.                     android:background="@color/gray_standard"  
  27.                     android:padding="@dimen/margin_standard">  
  28.   
  29.                     <ImageView  
  30.                         android:id="@+id/icon"  
  31.                         style="@style/BaseStyle.View"  
  32.                         android:layout_marginTop="@dimen/margin_small"  
  33.                         android:src="@drawable/window"/>  
  34.   
  35.                 </RelativeLayout>  
  36.             </RelativeLayout>  
  37.         </ScrollView>  
  38.     </android.support.v4.widget.SwipeRefreshLayout>  
  39.   
  40. </RelativeLayout>  

主页面代码:

[java] view plain copy
  1. import android.support.v4.widget.SwipeRefreshLayout;  
  2. public class SaleOrderDetailActivity extends Activity implements SwipeRefreshListener,{  
  3.   
  4. private SwipeRefreshLayout mSwipeRefreshLayout;//下拉刷新组件  
  5.   
  6.   @Override  
  7.     protected void onCreate(Bundle savedInstanceState) {  
  8.         super.onCreate(savedInstanceState);  
  9.         setContentView(R.layout.order_sale_detail_layout);  
  10.   
  11.         mSwipeRefreshLayout = $(R.id.srl_refresh);  
  12.         mSwipeRefreshLayout.setOnRefreshListener(this);  
  13.         mSwipeRefreshLayout.setColorSchemeResources(R.color.background_blue_standard, R.color.white, R.color.background_blue_standard, R.color.white);//设置颜色  
  14.     }  
  15.   
  16.     @Override  
  17.     public void onRefresh() {//下拉监听  
  18.         //刷新处理  
  19.     }  
  20.   


0 0
原创粉丝点击