【问题标题】:How to show circular progressBar with firestoreRecyclerView?如何使用 firestoreRecyclerView 显示循环进度条?
【发布时间】:2019-02-03 14:25:36
【问题描述】:

我在我的应用程序中使用FirestoreRecyclerView。我想在
FirestoreRecyclerView 加载数据时显示ProgressBar,如果RecyclerView 中没有要显示的数据,则显示TextView,其中包含文本“未找到数据”。如果有数据要显示,则隐藏TextViewProgressBar 并在RecyclerView 中显示数据。请指导如何实现这一点?

【问题讨论】:

    标签: java android firebase google-cloud-firestore firebaseui


    【解决方案1】:

    您可以使用两个布局作为主布局的子布局。 第一个布局包含TextViewProgressBar,其可见性设置为visible

    第二个布局是FirestoreRecyclerView,设置为invisiblegone

    一旦您的代码接收到该 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);
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-06-27
    • 1970-01-01
    • 2022-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多