优酷5.01 上拉刷新SwipeRefreshLayout

来源:互联网 发布:mac怎么编辑html 编辑:程序博客网 时间:2024/05/02 18:04

原创文章,欢迎转载。转载请注明:http://blog.csdn.net/seven2729/article/details/47979263

最近更新优酷发现好炫的刷新,以为是自定义的,好看又酷,找了半天。原来是系统自带的,碉堡了。有兴趣的瞅瞅吧!

布局与viewpager的有点像,贴点代码

<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/swipe_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout 
        android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:orientation="vertical">
   <Button 
       android:id="@+id/but_two_style"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:padding="11dp" 
       android:text="two_style"/>
   
   <ListView
       android:id="@+id/listview"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:padding="16dp" />
    </LinearLayout>


</android.support.v4.widget.SwipeRefreshLayout>

定义布局

private SwipeRefreshLayout mSwipeLayout;

在oncreat里面设置监听,太简单就不说了

mSwipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
mSwipeLayout.setOnRefreshListener(this);
// 设置下拉时的颜色
mSwipeLayout.setColorSchemeResources(R.color.color_bule,
R.color.color_bule, R.color.color_bule, R.color.color_bule);

/**
* do sth onRefresh
*/
public void onRefresh() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mSwipeLayout.setRefreshing(false);
}
}, 5000);
}

要是有需要的可以点击 下载源码

另附带之前上传的上拉刷新  资源

原创文章,欢迎转载。转载请注明:http://blog.csdn.net/seven2729/article/details/47979263

0 0