简单的使用SwipeRefreshLayout
来源:互联网 发布:视频后期编辑软件 编辑:程序博客网 时间:2024/06/06 05:27
SwipeRefreshLayout
google提供的一个可实现下拉刷新效果的widget,该控件有一下几个常用的方法:
1. setOnRefreshListener 添加下拉刷新的监听 2. setColorSchemeResources 设置进度条的颜色(最多设置四种颜色) 3. setRefreshing 显示或者隐藏进度条 4. isRefreshing 检测是否正在执行刷新操作
以下是代码示例
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" > <ScrollView android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/pull_refresh_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_margin="10dp" android:textColor="#201f1f" android:textSize="18sp" android:text="下拉刷新"/> </ScrollView></android.support.v4.widget.SwipeRefreshLayout>
public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // 绑定组件 final TextView refreshTv = (TextView) findViewById(R.id.pull_refresh_tv); final SwipeRefreshLayout mainLayout = (SwipeRefreshLayout)findViewById(R.id.activity_main); // 设置刷新时的颜色 mainLayout.setColorSchemeResources(R.color.blue,R.color.red,R.color.orange,R.color.green); // 设置刷新监听 mainLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { // 当文字下拉的时候,改变文字 refreshTv.setText("正在刷新"); // 做一个延时操作,模拟刷新过程 new Handler().postDelayed(new Runnable() { @Override public void run() { refreshTv.setText("刷新完成"); mainLayout.setRefreshing(false); } // 5000毫秒(5秒)后调用Run方法 },5000); } }); }}
0 0
- SwipeRefreshLayout的简单使用
- SwipeRefreshLayout 的简单使用
- 简单的使用SwipeRefreshLayout
- SwipeRefreshLayout的简单使用
- SwipeRefreshLayout 的简单使用
- 经验总结-SwipeRefreshLayout控件的简单使用
- SwipeRefreshLayout简单使用
- SwipeRefreshLayout简单使用
- Android下拉刷新SwipeRefreshLayout控件的简单使用
- SwipeRefreshLayout 配合fragment 下拉刷新的使用,超级简单
- CoordinatorLayout、SwipeRefreshLayout的使用
- Android SwipeRefreshLayout的使用
- SwipeRefreshLayout 的基本使用
- SwipeRefreshLayout的使用注意事项
- SwipeRefreshLayout的使用详解
- android 下拉刷新控件SwipeRefreshLayout简单使用
- Android中SwipeRefreshLayout的使用
- SwipeRefreshLayout使用注意的坑
- jqgrid 自定义搜索的实现 , 后台实现
- 自适应辛普森积分
- You don’t have permission to save the file “project.xcworkspace” in the folder
- 51单片机--矩阵键盘
- 项目在android studio中的问题
- 简单的使用SwipeRefreshLayout
- python第15天:异常
- Android color 平滑过渡计算
- Linux下如何查看哪些进程占用的CPU内存资源最多
- java http xml java通过http来访问一个xml文件的读取过程
- 导航栏隐藏的平滑切换
- 服务器选择Windows还是Linux
- 蓝桥杯
- MFC界面库BCGControlBar v25.2新版亮点:Dialogs和Grid控件等