AndroidStudio使用PullToRefresh下拉上拉刷新框架
来源:互联网 发布:stn快报淘宝店 编辑:程序博客网 时间:2024/06/06 13:23
导包
ptr支持ListView ExpandableListView GridView WebView
PullToRefresh是一个古老的下拉刷新框架,以至于并不能在androidstudio中使用gradle引包.https://github.com/chrisbanes/Android-PullToRefresh在上述网址中将lib包下载在androidstudio中import module将ptr类库import引来在setting的project struct中添加module即可
使用方法,以listview为例
<com.handmark.pulltorefresh.library.PullToRefreshListView xmlns:ptr="http://schemas.android.com/apk/res-auto" android:id="@+id/pulls_refresh_list_ClassDiaryMainActivity" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:cacheColorHint="#00000000" android:divider="@null" android:dividerHeight="10dp" android:scrollbars="none" //开始上拉和下拉刷新 ptr:ptrMode="both"> </com.handmark.pulltorefresh.library.PullToRefreshListView>
listview = (PullToRefreshListView) findViewById(R.id.pulls_refresh_list_ClassDiaryMainActivity); private void configPulltoRefreshListView() { //下拉刷新 ILoadingLayout startLoading = listview.getLoadingLayoutProxy( true, false); startLoading.setPullLabel("下拉刷新");// 刚下拉时显示的提示 startLoading.setRefreshingLabel("正在刷新中...");// 刷新时显示的提示 startLoading.setReleaseLabel("释放即可刷新");// 下拉达到一定距离时显示的提示 //上拉刷新 ILoadingLayout endLoading =listview.getLoadingLayoutProxy(false, true); endLoading.setPullLabel("上拉加载更多");// 刚上拉时显示的提示 endLoading.setRefreshingLabel("拼命加载中...");// 加载时的提示 endLoading.setReleaseLabel("释放即可加载更多");// 上拉达到一定距离时显示的提示 //1.只下拉刷新的监听器 listview.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener<ListView>() { @Override public void onRefresh(PullToRefreshBase<ListView> refreshView) { } }); //2.同时处理处理上拉刷新和下拉刷新的监听器 listview.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() { @Override public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) { //结束刷新的方法,否则下拉刷新进度条不会结束 listview.onRefreshComplete(); } @Override public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) { } }); }
更多方法
// set mode to BOTH mExpandList.setMode(Mode.BOTH); mExpandList.getLoadingLayoutProxy(false, true).setPullLabel(getString(R.string.pull_to_load)); mExpandList.getLoadingLayoutProxy(false, true).setRefreshingLabel(getString(R.string.loading)); mExpandList.getLoadingLayoutProxy(false, true).setReleaseLabel(getString(R.string.release_to_load)); mExpandList = (PullToRefreshExpandableListView) rootView.findViewById(R.id.expand_list); mExpandList.getRefreshableView().setGroupIndicator(null); mExpandList.getRefreshableView().setDivider(null); mExpandList.getRefreshableView().setSelector(android.R.color.transparent); mExpandList.getRefreshableView().setOnGroupClickListener(this); mExpandList.setOnRefreshListener(this);
阅读全文
0 0
- AndroidStudio使用PullToRefresh下拉上拉刷新框架
- 关于pulltorefresh框架使用 下拉刷新、 上拉加载
- PullToRefresh 上拉刷新,下拉加载数据 框架的简单使用
- PullToRefresh上拉刷新和下拉刷新
- 使用PullToRefresh实现下拉刷新和上拉加载
- 使用PullToRefresh实现下拉刷新和上拉加载
- 【Android-PullToRefresh】 上拉刷新、下拉加载 使用详解
- 使用PullToRefresh实现下拉刷新和上拉加载
- 使用PullToRefresh区分下拉刷新和上拉加载
- 使用PullToRefresh实现下拉刷新和上拉加载
- 使用PullToRefresh实现下拉刷新和上拉加载
- 使用PullToRefresh实现下拉刷新和上拉加载
- 使用PullToRefresh实现下拉刷新和上拉加载
- 使用PullToRefresh实现下拉刷新和上拉加载
- Android PullToRefresh下拉刷新,上拉加载的使用详解
- 使用PullToRefresh实现下拉刷新和上拉加载
- 使用PullToRefresh实现下拉刷新和上拉加载
- 使用PullToRefresh实现下拉刷新和上拉加载
- 使用pyinstaller将Python3.6文件打包成可执行文件
- jquery easyui DataGrid 数据表格 属性
- vue过渡动画
- Java中介者模式
- 创建存储过程 /////调用存储过程
- AndroidStudio使用PullToRefresh下拉上拉刷新框架
- git常用命令
- JAVA断言
- Android性能优化(面试必备)
- Iterator(迭代器)的一般用法
- Spring Boot -- Spring Data Jpa(1)
- windows 安装oracle 11
- 3.1 类的声明与对象的定义【C++】
- oracle解锁用户