Android Studio第十三期 - RecycleView所有用法

    綜合了一下hongyang和loader的RecycleView的所有場景用法:

    1.ListView列表分頁用法核心代碼:

private void createAdapter(){
    mAdapter = new RecycleAdapter1(this);
    LinearLayoutManager mLinearLayoutManager1 = new LinearLayoutManager(this);
    mLinearLayoutManager1.setOrientation(OrientationHelper.VERTICAL);
    recyclerView.setLayoutManager(mLinearLayoutManager1);
    recyclerView.setAdapter(mAdapter);
}

    效果如下圖:

    wKiom1flARPDMtE5ABpuOKO98Tk420.gif

    2.GridView列表分頁用法核心代碼:

private void createAdapter(){
    mAdapter = new RecycleAdapter2(this);
    recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
    recyclerView.setAdapter(mAdapter);
}

    效果如下圖:

    wKioL1fk_13AHQlRABnF9lC5vAo823.gif

    3.ListView列表AddHeadAndAddFooter用法核心代碼:

    private void createAdapter() {
        ll_header = (LinearLayout) View.inflate(this,
                R.layout.activity_addheader, null);
        ll_footer = (LinearLayout) View.inflate(this,
                R.layout.activity_addfooter, null);
        mAdapter = new RecycleAdapter3(this);
        LinearLayoutManager mLinearLayoutManager1 = new LinearLayoutManager(this);
        mLinearLayoutManager1.setOrientation(OrientationHelper.VERTICAL);
        recyclerView.setLayoutManager(mLinearLayoutManager1);
//        recyclerView.setAdapter(mAdapter);

    }

    private void addAdapter() {
        mHeaderAndFooterWrapper = new HeaderAndFooterWrapper(mAdapter);
        mHeaderAndFooterWrapper.addHeaderView(ll_header);
        mHeaderAndFooterWrapper.addFootView(ll_footer);
        recyclerView.setAdapter(mHeaderAndFooterWrapper);
    }

    效果如下圖:

    wKiom1fk_3zgS3dfABg_ri8v8yc613.gif

    4.GridView列表AddHeadAndAddFooter用法核心代碼:

   private void createAdapter() {
        ll_header = (LinearLayout) View.inflate(this,
                R.layout.activity_addheader, null);
        ll_footer = (LinearLayout) View.inflate(this,
                R.layout.activity_addfooter, null);
        mAdapter = new RecycleAdapter4(this);
        recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
//        recyclerView.setAdapter(mAdapter);

    }

    private void addAdapter() {
        mHeaderAndFooterWrapper = new HeaderAndFooterWrapper(mAdapter);
        mHeaderAndFooterWrapper.addHeaderView(ll_header);
        mHeaderAndFooterWrapper.addFootView(ll_footer);
        recyclerView.setAdapter(mHeaderAndFooterWrapper);

    }

    效果如下圖:

    wKiom1flAHywNJFkAByJ-Pe18hk218.gif

    附:提供了幾個常用控件的使用:

    1.SwipeReFreshLayout的用法:

    onRefresh();

    2.ShapeLoading的用法:

    ShowLoadingUtil.showProgressDialog2(MainActivity4.this, "正在加載...");

    這回夠誠意吧~麼麼噠~下班肥家~吃飯飯~

    地址:https://github.com/geeklx/MyApplication/tree/master/p010_recycleviewall

    

    

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章