PullToRefreshScrollView的使用
2017-10-20 16:12
381 查看
===例如无限轮播和list列表联动
//布局中::
//这里放得是要联动的内容:
//例如放得ViewPager和XListView
//”com.example.administrator.pulltorefresh_demo.MyListView”引用的ListView控件是自己创建的MyListView:
//MyListView类继承ListView
//例如内容在Fragment里:
//1.找到控件:
//2.得到bean包的数据list;
//3.代码示例:
//图片的适配器::地址:http://blog.csdn.net/biggrand/article/details/78243112
//ListView数据的适配器:地址:http://blog.csdn.net/biggrand/article/details/78202640
//上拉加载和下拉刷新的方法,,可以借鉴地址: http://blog.csdn.net/biggrand/article/details/78206922
4000
//布局中::
<com.handmark.pulltorefresh.library.PullToRefreshScrollView xmlns:ptr="http://schemas.android.com/apk/res-auto" android:id="@+id/pull_lv" 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">
//这里放得是要联动的内容:
//例如放得ViewPager和XListView
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <android.support.v4.view.ViewPager android:id="@+id/vp" android:layout_width="match_parent" android:layout_height="200dp"> </android.support.v4.view.ViewPager> <com.example.administrator.pulltorefresh_demo.MyListView android:id="@+id/scroll_list" android:layout_width="match_parent" android:layout_height="match_parent"> </com.example.administrator.pulltorefresh_demo.MyListView> </LinearLayout> </com.handmark.pulltorefresh.library.PullToRefreshScrollView>
//”com.example.administrator.pulltorefresh_demo.MyListView”引用的ListView控件是自己创建的MyListView:
//MyListView类继承ListView
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, expandSpec); } /* @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); }*/ }
//例如内容在Fragment里:
//1.找到控件:
PullToRefreshScrollView和ViewPager和ListView(也就是MyListView)和ILoadingLayout startLabels;;
//2.得到bean包的数据list;
//3.代码示例:
//失去焦点 lv.setFocusable(false); //轮播图 lunBoTu(); //1.获取网络数据 getDataFromNet(); //2.设置刷新模式 pull_lv.setMode(PullToRefreshBase.Mode.BOTH); //3.通过getLoadingLayoutProxy 方法来指定上拉和下拉时显示的状态的区别(也就是设置向下拉的时候头部里面显示的文字) startLabels = pull_lv.getLoadingLayoutProxy(true, false); startLabels.setPullLabel("下拉刷新"); startLabels.setRefreshingLabel("正在刷新..."); startLabels.setReleaseLabel("放开刷新"); ILoadingLayout endLabels = pull_lv.getLoadingLayoutProxy(false, true); endLabels.setPullLabel("上拉刷新"); endLabels.setRefreshingLabel("正在载入..."); endLabels.setReleaseLabel("放开刷新..."); pull_lv.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ScrollView>() { @Override public void onPullDownToRefresh(PullToRefreshBase<ScrollView> refreshView) { //下拉刷新的方法,,可以借鉴地址: //(http://blog.csdn.net/biggrand/article/details/78206922) getRefreshData(); } @Override public void onPullUpToRefresh(PullToRefreshBase<ScrollView> refreshView) { //上拉加载的方法,,可以借鉴地址: //(http://blog.csdn.net/biggrand/article/details/78206922) page_num++; getDataFromNet(); } });
//图片的适配器::地址:http://blog.csdn.net/biggrand/article/details/78243112
//ListView数据的适配器:地址:http://blog.csdn.net/biggrand/article/details/78202640
//上拉加载和下拉刷新的方法,,可以借鉴地址: http://blog.csdn.net/biggrand/article/details/78206922
4000
相关文章推荐
- 使用PullToRefreshScrollView实现无线轮播和ListView同时刷新加载
- 使用开源的PullToRefreshScrollView scrollTo和scrollby遇到的问题
- 关于PullToRefreshLayout和PullToRefreshScrollView同时使用代码报错的问题
- PullToRefreshScrollView的使用
- PullToRefreshScrollView的使用 +Banner
- Android_横向滑动菜单, HorizontalScrollView,Fragment,Viewpager结合使用 +pullToRefreshListView
- android studio 环境下使用PullToRefreshScrollView
- 使用开源的PullToRefreshScrollView scrollTo和scrollby遇到的问题
- PullToRefreshScrollView的使用
- PullToRefreshScrollView的使用
- PullToRefreshScrollView的使用
- Android PullToRefreshScrollView、AutoHeightListView、AutoScrollViewPager的使用
- PullToRefreshScrollView的使用
- 使用PullToRefreshScrollView
- PullToRefreshScrollView的scrollTo方法的使用
- PullToRefreshScrollView的使用
- PullToRefreshScrollView的使用
- PullToRefreshScrollView的使用
- PullToRefreshscrollview的具体使用
- 轮播图,并且在轮播图下用listview显示,填充listView让他全屏显示,可以使用PullToRefreshScrollView上下刷新,加载