您的位置:首页 > 其它

优酷5.01 上拉刷新SwipeRefreshLayout

2015-08-25 16:37 176 查看
原创文章,欢迎转载。转载请注明: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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: