Skip to content

Use RecyclerViews to show subViews in Lists.

rutura edited this page Apr 16, 2017 · 1 revision
  • Quick Code:
 mRecyclerView = new RecyclerView(this);
        mHorizontalManager = new LinearLayoutManager(this,
                LinearLayoutManager.HORIZONTAL, false);
        mVerticalManager = new LinearLayoutManager(this,
                LinearLayoutManager.VERTICAL, false);
        mVerticalGridManager = new GridLayoutManager(this,
                2, /* Number of grid columns */
                LinearLayoutManager.VERTICAL, /* Orient grid vertically */
                false);
        mHorizontalGridManager = new GridLayoutManager(this,
                3, /* Number of grid rows */
                LinearLayoutManager.HORIZONTAL, /* Orient grid horizontally */
                false);
        //Connector line decorations for vertical grid
        mConnectors = new ConnectorDecoration(this);
        //Stagger the vertical grid
        mVerticalGridManager.setSpanSizeLookup(new GridStaggerLookup());
        mAdapter = new SimpleItemAdapter(this);
        mAdapter.setOnItemClickListener(this);
        mRecyclerView.setAdapter(mAdapter);
        //Apply margins decoration to all collections
        mRecyclerView.addItemDecoration(new InsetDecoration(this));
        //Default to vertical layout
        selectLayoutManager(R.id.action_vertical);
        setContentView(mRecyclerView);
Clone this wiki locally