Getting started with version 0.4

Tonic Artos edited this page Apr 1, 2015 · 2 revisions

These are instructions for version 0.4 only.

Adding to your project

Lastest Packaged Version
Maven central version


The easiest way to add SuperSLiM to your project is to register it as a dependency in your build.gradle file.

dependencies {
    compile 'com.tonicartos:superslim:0.4.+'

Legacy Maven

For people using maven as a build system the following may be useful. Substitute VERSION with the latest version number displayed in the maven badge above.



Manual AAR with Gradle
The .aar file for SuperSLiM is available from Maven Central and can be added manually to your libs folder inside your project. Add the following to your build.gradle file to compile .aar packages in your lib folder.

dependencies {
     compile fileTree(include ['*.aar'], dir: 'libs')

Basic usage

Create your recycler views in the usual way, create a LayoutManager, register one or more SectionLayoutManagers, and attach an adapter for the data to be displayed:

public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // Add layout manager to recycler view.
    RecyclerView recyclerView = 
        (RecyclerView) view.findViewById(;
    recyclerView.setLayoutManager(new LayoutManager(getActivity()));

The adapter has to do a little more work than a regular RecyclerView.Adapter. The adapter must ensure configuration details for sections are embedded in bound item views using layout parameters:

public void onBindViewHolder(ViewHolder holder, int position) {
    final Item item = mItems.get(position);

    // A content binding implementation.

    /** Embed section configuration. **/
    final LayoutParams params = holder.getLayoutParams();


    // Position of the first item in the section. This doesn't have to
    // be a header. However, if an item is a header, it must then be the
    // first item in a section.

It is important to note that setting the section manager and first position of each section is required for all views provided by the adapter.

As shown here with the section headers, you can embed any configuration using XML attributes rather than using LayoutParams directly:

<!-- TextView as a section header. -->
<!-- Add android:textDirection="locale" to support RTL languages. -->
    tools:text="Header Item"

Make sure you have the right number of view types, and be sure to inflate the header correctly when creating your ViewHolders:

public int getItemViewType(int position) {
    return mItems.get(position).isHeader ? 

public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    LayoutInflater inflater = LayoutInflater.from(parent.getContext());
    View view;
    if (viewType == VIEW_TYPE_HEADER) {
        view = inflator.inflate(R.layout.header_item, parent, false);
    } else {
        view = inflater.inflate(R.layout.content_item, parent, false);
    return new ViewHolder(view);

Read the [User's Guide](User's guide for version 0.4) for more information.

Versioned Pages


[Getting Started](Getting started with version 0.4)
[User's Guide](User's guide for version 0.4)

version5 (WIP)

User documentation
[Basic usage](A simple tutorial)
[Advanced usage](All the cool things)
[SuperSLiM and RxJava](Using SuperSLiM with RxJava)

Developers documentation
[The section graph](The section graph)
[Tracking data changes](Tracking data changes)
[Configuration transformations](Configuration transformations)
[Layout helpers](Layout helpers)
[Section configuration](Section configuration)
[Section state](Section state)
[Section layout managers](Section layout managers)
[Header layout managers](Header layout managers)

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.