Antwort

15

Sie können es einfach tun, indem Sie die Sichtbarkeit von Fortschrittsbalken und Recyclerview umschalten.

In Ihrem Layout,

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
     <ProgressBar 
      android:id="@+id/progress_bar" 
      style="?android:progressBarStyle" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      /> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/recycler_view" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:visibility="gone" 
      /> 
</FrameLayout> 

Nach oben Layout, bevor Sie Ihre Daten bereit ist, wird progressbar auf dem Bildschirm zeigt. Nachdem Ihre Daten fertig sind, können Sie die Sichtbarkeit ändern.

mRecyclerAdapter.setData(mData); // need to implement setter method for data in adapter 
mRecyclerAdapter.notifyDataSetChanged(); 
mRecyclerView.setVisibility(View.VISIBLE); 
mProgressBar.setVisibility(View.GONE); 

Ich hoffe, es wird für Sie nützlich sein.

+9

Wie ist es möglich, dieselben Animationen für die Recyclerview-Elemente zu erstellen? –