答えて

15

これは、プログレスバーとリサイクルビューの表示を切り替えるだけで簡単に実行できます。あなたのデータの準備ができる前に、上記のレイアウトによると、あなたのレイアウトでは

<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> 

は、プログレスバーが画面上に表示されています。データが準備できたら、そのような表示を切り替えることができます。

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

希望すると便利です。

+9

リサイクルビューアイテムで同じアニメーションをどのように行うことができますか? –

関連する問題