title: SwipeRefreshLayout with a RecyclerView empty and a TextView
body: <p>The problem I have is perfectly explained here <a href="http://innodroid.com/blog/post/recycler-empty-swipe-refresh" rel="nofollow">http://innodroid.com/blog/post/recycler-empty-swipe-refresh</a> and is realted to dealing with emtpy recyclerview inside a SwipeRefreshLayout. The solution is in that link but I don't have idea how to implement it.</p>
  
  <p>This is my code</p>
  
  <pre><code>&lt;android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
                                                android:id="@+id/swipeRefresh"
                                                android:layout_width="match_parent"
                                                android:layout_height="match_parent"&gt;
      &lt;FrameLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
          &lt;android.support.v7.widget.RecyclerView
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:background="@color/background"
              android:id="@+id/rv"
              xmlns:android="http://schemas.android.com/apk/res/android"/&gt;
  
          &lt;TextView
              android:id="@+id/empty_view"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:gravity="center"
              android:visibility="gone"
              android:text="No hay conexión con el servidor" /&gt;
      &lt;/FrameLayout&gt;
  
  &lt;/android.support.v4.widget.SwipeRefreshLayout&gt;
  </code></pre>
  
  <p>and this is my Fragment where I cannot extend another class because I already extend Fragment. </p>
  
  <pre><code>public class FragmentNoticias extends Fragment {
  
      private RVAdapter adapter;
      private String mNoticias = "Resumen";
      private SwipeRefreshLayout refreshLayout;
      private Cursor cursor;
  
      public interface RefreshCall {
  
          boolean onMethodRefreshCall();
      }
  
      private RefreshCall mRefreshCall;
  
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          cursor = FeedDatabase.getInstance(getActivity()).obtenerEntradas(mNoticias);
  
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          super.onCreateView(inflater, container, savedInstanceState);
  
          View root = inflater.inflate(R.layout.recycler_view, container, false);
          RecyclerView rv = (RecyclerView) root.findViewById(R.id.rv);
  
          rv.setHasFixedSize(true);
  
          //hace que el RecyclerView se muestre por defecto con un layout linear
          LinearLayoutManager llm = new LinearLayoutManager(getActivity());
          rv.setLayoutManager(llm);
  
          adapter = new RVAdapter(
                  getActivity(),
                  cursor);
          rv.setAdapter(adapter);
  
  
          // Obtener el refreshLayout
          refreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.swipeRefresh);
  
          refreshLayout.setColorSchemeResources(
                  R.color.s1,
                  R.color.s2,
                  R.color.s3
          );
  
          // Iniciar la tarea asíncrona al revelar el indicador
          refreshLayout.setOnRefreshListener(
                  new SwipeRefreshLayout.OnRefreshListener() {
                      @Override
                      public void onRefresh() {
                          new HackingBackgroundTask().execute();
                      }
                  }
          );
  
          try {
              this.mRefreshCall = ((RefreshCall) getActivity());
          } catch (ClassCastException e) {
              throw new ClassCastException("Activity must implement AdapterCallback.");
          }
  
  
          return root;
      }
  
      private class HackingBackgroundTask extends AsyncTask&lt;Void, Void, Cursor&gt; {...}
  </code></pre>
  
  <p>How should I implement the solution of the link to use it in my fragment ? I'm confused.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Thanks to the first answer it works but the refresh circle animation isn't showed correctly yet.</p>