title: Adding dividers in GridLayout RecyclerView
body: <p>I tried adding horizontal dividers to my GridLayout RecyclerView. But for some reason, the dividers didn't show up.</p>
  
  <p><strong>As an alternative, I used the addItemDecoration method with 2 parameters, where the second parameter is the index after which to add the ItemDecoration.</strong></p>
  
  <pre><code>RecyclerView r = (RecyclerView) findViewById(R.id.recycler_view);
  r.setAdapter(new AppAdapter(this, fetchData());
  r.setLayoutManager(new GridLayoutManager(this, 5));
  r.addItemDecoration(new DividerItemDecoration(this, GridLayoutManager.HORIZONTAL), 2);
  </code></pre>
  
  <p><strong>And it force closed with the following exception:</strong></p>
  
  <pre><code>Caused by: java.lang.IndexOutOfBoundsException: Index: 2, Size: 0
  </code></pre>
  
  <p><strong>What does this Size signify? Why is it zero?</strong></p>
  
  <p>Could it be because I am using this RecyclerView in an Activity instead of a Fragment?</p>
  
  <p>P.S.: There is no issue with the adapter; it is not empty.</p>