zoukankan      html  css  js  c++  java
  • 每日学习

    今日份学习,新闻app当然得有上拉下拉了,所以smartRefreshLayout得好好学一下,

    <?xml version="1.0" encoding="utf-8"?>
    <com.scwang.smartrefresh.layout.SmartRefreshLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/srl_fresh"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="com.wen.asyl.pulltorefreshdemo.MainActivity">
    
        <android.support.v7.widget.RecyclerView
            android:id="@+id/rv_list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:overScrollMode="never"
            android:background="#fff"/>
    
    </com.scwang.smartrefresh.layout.SmartRefreshLayout>
    recycleAdapter = new RecycleAdapter(MainActivity.this , mDatas );
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    //设置布局管理器
    rvList.setLayoutManager(layoutManager);
    //设置为垂直布局,这也是默认的
    layoutManager.setOrientation(OrientationHelper.VERTICAL);
    //设置Adapter
    rvList.setAdapter(recycleAdapter);
    //设置 Header 为 贝塞尔雷达 样式
    srfresh.setRefreshHeader(new BezierRadarHeader(this).setEnableHorizontalDrag(true));
    //设置 Footer 为 球脉冲 样式
    srfresh.setRefreshFooter(new BallPulseFooter(this).setSpinnerStyle(SpinnerStyle.Scale));
    srfresh.setOnRefreshListener(new OnRefreshListener() {
        @Override
        public void onRefresh(final RefreshLayout refreshlayout) {
            //延时展示,延时2秒
            mHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    initData();
                    recycleAdapter.refresh(mDatas);//刷新加载数据
                    refreshlayout.finishRefresh();
                }
            },2000);
    
        }
    });
    srfresh.setOnLoadMoreListener(new OnLoadMoreListener() {
        @Override
        public void onLoadMore(final RefreshLayout refreshlayout) {
            mHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    initData();
                    recycleAdapter.refresh(mDatas);
                    refreshlayout.finishLoadMore();
                }
            },2000);
    
        }
    });
    srfresh.setEnableLoadMore(true);
    srfresh.autoRefresh();
    作者:哦心有
    本文版权归作者和博客园共有,欢迎转载,但必须给出原文链接,并保留此段声明,否则保留追究法律责任的权利。
  • 相关阅读:
    麦茶商务的网站
    jQuery Ajax 实例 ($.ajax、$.post、$.get)
    关于meta知多少
    WebApp之Meta标签
    html5开发之viewport使用
    bootstrap
    8.8&8.9 dp训练小结
    2019.8.10小结
    2019.8.17 小结
    [NOI2001]炮兵阵地 题解
  • 原文地址:https://www.cnblogs.com/haobox/p/14909312.html
Copyright © 2011-2022 走看看