PullToRefreshScrollView
来源:互联网 发布:矩阵键盘硬件设计 编辑:程序博客网 时间:2024/05/21 23:28
//////////////////////////
布局
/////////////////////////////////////////////////////////////////////////////////////
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:ptr="http://schemas.android.com/apk/res-auto" > <com.handmark.pulltorefresh.library.PullToRefreshScrollView android:id="@+id/refresh_scroll_view" android:layout_width="match_parent" android:layout_height="match_parent" ptr:ptrAnimationStyle="flip" ptr:ptrDrawable="@drawable/default_ptr_flip" ptr:ptrHeaderBackground="#383838" ptr:ptrHeaderTextColor="#FFFFFF"> <!--在scrollView中添加组件 viewPager和ListView 注意:在scrollView中只能有一个子孩子--> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <com.youth.banner.Banner android:layout_width="match_parent" android:layout_height="200dp" android:id="@+id/banner" ></com.youth.banner.Banner> <!--listview引用类里面的 包名+类名--> <com.example.dszfx.MyListView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/listview" ></com.example.dszfx.MyListView> </LinearLayout> </com.handmark.pulltorefresh.library.PullToRefreshScrollView></RelativeLayout>/////////////////////////////////////////////// 主函数//////////////////////////////////////////////////////////
public void prs(){ //1.设置模式 rsv.setMode(PullToRefreshBase.Mode.BOTH); //2.通过调用getLoadingLayoutProxy方法,设置下拉刷新状况布局中显示的文字 ,第一个参数为true,代表下拉刷新 ILoadingLayout headLables = rsv.getLoadingLayoutProxy(true, false); headLables.setPullLabel("下拉刷新"); headLables.setRefreshingLabel("正在刷新"); headLables.setReleaseLabel("松开刷新"); //2.设置上拉加载底部视图中显示的文字,第一个参数为false,代表上拉加载更多 ILoadingLayout footerLables = rsv.getLoadingLayoutProxy(false, true); footerLables.setPullLabel("上拉加载"); footerLables.setRefreshingLabel("正在载入..."); footerLables.setReleaseLabel("松开加载更多"); //3.设置监听事件 rsv.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ScrollView>() { @Override public void onPullDownToRefresh(PullToRefreshBase<ScrollView> refreshView) { addToTop();//请求网络数据,并更新listview组件 refreshComplete();//数据加载完成后,关闭header,footer } @Override public void onPullUpToRefresh(PullToRefreshBase<ScrollView> refreshView) { addToBottom();//请求网络数据,并更新listview组件 refreshComplete();//数据加载完成后,关闭header,footer } });}public void refreshComplete(){ new Handler().postDelayed(new Runnable() { @Override public void run() { rsv.onRefreshComplete(); } },1000);}/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////public void setadapter(){ if(adapter==null){ adapter=new MyAdapter(getActivity(),list2); listview.setAdapter(adapter); }else{ adapter.notifyDataSetChanged(); }}
listview引用的类
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
package com.example.dszfx;import android.content.Context;import android.util.AttributeSet;import android.widget.ListView;/** * Created by Administrator on 2017/10/24 0024. */public class MyListView extends ListView { public MyListView(Context context) { super(context); } public MyListView(Context context, AttributeSet attrs) { super(context, attrs); } public MyListView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, heightMeasureSpec); }}
阅读全文
0 0
- PullToRefreshScrollView
- PullToRefreshScrollView
- PullToRefreshScrollView
- PullToRefreshScrollView
- PullToRefreshScrollView
- PullToRefreshScrollView
- 使用PullToRefreshScrollView
- PullToRefreshScrollView+ListView
- PullToRefreshScrollView用法
- PullToRefreshScrollView结合StickyHeaderGridView
- PullToRefreshScrollView嵌套两个GridView
- Android PullTorefreshScrollview回到顶部
- PullToRefreshScrollView的使用
- PullToRefreshScrollView显示不完全
- PullToRefreshScrollView嵌套viewpager
- PullToRefreshScrollView 添加滚动监听
- PullToRefreshScrollView的使用
- PullToRefreshScrollView+ViewPager+MyListView
- Ubuntu 14.04下jdkHadoop2.8集群安装配置教程并运行wordcount实例
- 【队内胡策】令咒
- 安卓如何优雅的加载图片问题探究
- leetcode---partition-list---链表
- 基础知识(面试用)
- PullToRefreshScrollView
- 使用Vue制作幻灯片
- 2017CCPC<哈尔滨站> 赛后总结
- [PL/SQL] oracle sql语句 存储过程执行慢,单独执行快
- JS学习笔记
- 常用的排序算法
- Vuforia提高识别图星级
- Fragment 工具类,搞定Fragment的基本使用
- Spring MVC配置及测试