如何显示与firestoreRecyclerView圆形进度?

问题描述 投票:0回答:1

我在我的应用程序使用FirestoreRecyclerView。我想说明ProgressBarFirestoreRecyclerView加载数据,如果没有数据以RecyclerView显示则显示TextView其中有文本“没有发现数据”。如果有数据显示然后隐藏既TextViewProgressBar和显示数据RecyclerView.Please指导如何实现这一目标?

java android firebase google-cloud-firestore firebaseui
1个回答
0
投票

你可以使用两种布局为主要布局的孩子。第一个布局包含两个TextViewProgressBar其可见性设置为visible

然后,第二布局是被设定为FirestoreRecyclerViewinvisiblegone

只要你的代码收到该RecyclerView数据,隐藏第一布局,使RecyclerView可见。

下面是一个例子:

MainLayout.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!-- the progress layout -->
    <RelativeLayout
        android:id="@+id/layout_progress"
        android:visibility="visible"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Loading data"/>
        <ProgressBar
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:max="100"
            android:progress="0"/>
    </RelativeLayout>

    <FirestoreRecyclerView
        android:id="@+id/firestoreRecyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone" />
</LinearLayout>

//...
//When we received all the data to display in recyclerView, do this
layout_progress.setVisibility(View.GONE);
firestoreRecyclerView.setVisibility(View.VISIBLE);
© www.soinside.com 2019 - 2024. All rights reserved.