title: Implementing EmptyView with Recyclerview with Sqlite Cursor
body: <p>For the past few hours I've been trying to install an emptyview for my RecyclerView. The solutions I've found involved creating new classes and putting the emptyview on the level as the recyclerview in the XML. I understand the latter but I haven't seen of the Java solutions for use with SQLite databases. The attempt I used will put in the emptyview but then the recyclerview information wont be presented. Can someone help me resolve this issue? </p>
  
  <p>Here is my Activity: </p>
  
  <pre><code>public class DisplayActivity extends AppCompatActivity implements         
  LoaderManager.LoaderCallbacks&lt;Cursor&gt;{
  
  private static final int PRESCRIPTION_LOADER = 0;
  private CustomCursorAdapter mAdapter;
  RecyclerView mRecyclerView;
  private static final String TAG = "MainTagName";
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_display);
  
      mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
      ViewGroup emptyView = findViewById(R.id.empty_view);
      mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
      mRecyclerView.addItemDecoration(new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL));
  
  
  
      mAdapter = new CustomCursorAdapter(this);
      mRecyclerView.setAdapter(mAdapter);
  
  
      if (mAdapter.getItemCount()==0) {
          mRecyclerView.setVisibility(View.GONE);
          emptyView.setVisibility(View.VISIBLE);
      }else {
          mRecyclerView.setVisibility(View.VISIBLE);
          emptyView.setVisibility(View.GONE);
  
      }
  
      //Kick off the loader
      getLoaderManager().initLoader(PRESCRIPTION_LOADER,null,this);
  
      //….
  
  
  @Override
  public Loader&lt;Cursor&gt; onCreateLoader(int i, Bundle bundle) {
    //….     
  
  @Override
  public void onLoadFinished(Loader&lt;Cursor&gt; loader, Cursor data) {
      mAdapter.swapCursor(data);
      Log.i(TAG,"Loader Manager Loading Finished: " + data.getCount());
  
  
  }
  
  
  
  @Override
  public void onLoaderReset(Loader&lt;Cursor&gt; loader) {
      mAdapter.swapCursor(null);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Here is my RecyclerView Adapter: </p>
  
  <pre><code> public class CustomCursorAdapter extends     
   RecyclerView.Adapter&lt;CustomCursorAdapter.MyTaskViewHolder&gt;{
  
  private Cursor mCursor;
  private Context mContext;
  
  
  public CustomCursorAdapter (Context mContext){
      this.mContext = mContext;
  }
  
  @Override
  public MyTaskViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycle_item, parent, false);
      return new MyTaskViewHolder (view);
  }
  
  @Override
  public void onBindViewHolder(CustomCursorAdapter.MyTaskViewHolder holder, int position) {
      mCursor.moveToPosition(position);
  
   //….
  }
  
  @Override
  public int getItemCount() {
      if (mCursor ==null){
          return 0;
      }
      return mCursor.getCount();
  }
  
  public Cursor swapCursor(Cursor c) {
      if (mCursor == c){
          return null;
      }
      Cursor temp = mCursor;
      this.mCursor = c;
  
      if (c != null){
          this.notifyDataSetChanged();
      }
      return temp;
  }
  
  class MyTaskViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
    //….
  </code></pre>
  
  <p>Here is my RecyclerView XML: </p>
  
  <pre><code>  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;RelativeLayout 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:layout_width="match_parent"
  android:layout_height="match_parent"
  app:layout_behavior="@string/appbar_scrolling_view_behavior"
  tools:context="com.cloiud.DisplayActivity"
  tools:showIn="@layout/activity_display"&gt;
  
  &lt;android.support.v7.widget.RecyclerView
      android:id="@+id/recyclerView"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      /&gt;
  
  &lt;include layout="@layout/empty_view"/&gt;
  </code></pre>
  
  <p></p>
  
  <p>And here is my emptyview XML: </p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/empty_view"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:visibility="gone"
  android:gravity="center"&gt;
  
   //....
  </code></pre>