title: Empty View on a RecyclerView
body: <p>In an app I am working on, I am using a Recycler View to show a list of items. I would like the list to display some view (For example, a text view) when the list is empty. I know that with ListViews, one could call <code>setEmptyView</code>, but RecyclerView has no such method. </p>
  
  <p>I have tried setting the visibility of a view to GONE, and making it visible when the RecyclerView dataset is empty, but adding any view to the layout file where the RecyclerView is defined leads to an error:</p>
  
  <pre><code>Attempt to invoke virtual method 'boolean 
  android.support.v7.widget.RecyclerView$ViewHolder.shouldIgnore()' on a null 
  object reference
  </code></pre>
  
  <p>What is the best way to go about what I am doing?</p>
  
  <p>For more info, the RecyclerView is held inside a Fragment, and the layout is inflated in the onCreateView function. </p>
  
  <pre><code>@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      View view = inflater.inflate(R.layout.fragment_grocerylist, container, false);
  
      rv = view.findViewById(R.id.grocery_list);
  
      dh = new DatabaseHandler(view.getContext());
  
      dataset = dh.getGroceries();
  
      // Set the adapter
      if (view instanceof RecyclerView) {
          Context context = view.getContext();
          RecyclerView recyclerView = (RecyclerView) view;
          recyclerView.setLayoutManager(new LinearLayoutManager(context));
  
          adapter = new GroceryListRecyclerViewAdapter(dataset,mListener,this);
          recyclerView.setAdapter(adapter);
      }
  
      ItemTouchHelper.Callback callback = new SimpleTouchHelperCallback(adapter);
      ith = new ItemTouchHelper(callback);
      ith.attachToRecyclerView(rv);
  
      DividerItemDecoration div = new DividerItemDecoration(rv.getContext(),
              DividerItemDecoration.VERTICAL);
  
      rv.addItemDecoration(div);
  
      return view;
  }
  </code></pre>
  
  <p>The XML: </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:id="@+id/grocery_list" android:name="com.github.jlcarveth.grocer.layout.fragment.GroceryListFragment"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_marginLeft="0dp"
  android:layout_marginRight="0dp"
  app:layoutManager="LinearLayoutManager"  tools:context="com.github.jlcarveth.grocer.layout.fragment.GroceryListFragment"   tools:listitem="@layout/grocery_item"/&gt;
  </code></pre>