【发布时间】:2015-12-26 20:41:54
【问题描述】:
【问题讨论】:
标签: android android-animation material-design android-recyclerview
【问题讨论】:
标签: android android-animation material-design android-recyclerview
您可以通过切换进度条和回收器视图的可见性来简单地做到这一点。
在你的布局中,
<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);
希望对你有用。
【讨论】: