/** * 添加头部View LoopView * * <p>这里使用的是LoopView开源项目,项目地址:https://github.com/xuehuayous/Android-LoopView * * @return void */ private void addFooterView() { LayoutInflater inflater = LayoutInflater.from(this); FrameLayout layout = (FrameLayout) inflater.inflate(R.layout.recycler_header, null); AdLoopView mAdLoopView = (AdLoopView) layout.findViewById(R.id.home_frag_rotate_vp); mWrapAdapter.addFooterView(layout); // 初始化LoopView数据 String json = LocalFileUtils.getStringFormAsset(this, "loopview.json"); mAdLoopView.refreshData(json); mAdLoopView.startAutoLoop(); }
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getTitle().toString().equals(refreshDate)) { // 初始化数据,这里模拟网络获取数据 PictureData pictureData = initData(); mAdapter.setItemLists(pictureData.pictures); // 数据适配器设置数据 mWrapAdapter.notifyDataSetChanged(); // 包装类适配器刷新数据 } else if (item.getTitle().toString().equals(addHeader)) { addHeaderView(); } else if (item.getTitle().toString().equals(addFooter)) { addFooterView(); } return true; }