@Override public void onRefresh(BaseHeaderView baseHeaderView) { baseHeaderView.postDelayed( new Runnable() { @Override public void run() { page = 1; List<String> datas = getData(5); list.clear(); list.addAll(datas); adapter.setData(list); headerView.stopRefresh(); } }, 3000); }
@Nullable @Override public View onCreateView( LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { view = inflater.inflate(R.layout.fragment1, container, false); recyclerView = findViewById(R.id.list); headerView = findViewById(R.id.header); footerView = findViewById(R.id.footer); list = getData(15); adapter = new RecyclerViewAdapter(); adapter.setData(list); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setAdapter(adapter); headerView.setOnRefreshListener(this); footerView.setOnLoadListener(this); return view; }