Как показать круговой прогрессбар с firestoreRecyclerView? - PullRequest
0 голосов
/ 03 февраля 2019

Я использую FirestoreRecyclerView в моем приложении.Я хочу показать ProgressBar при
FirestoreRecyclerView при загрузке данных, и если нет данных для отображения в RecyclerView, тогда покажите TextView с текстом «данные не найдены».Если есть данные, которые нужно отобразить, то скройте и TextView, и ProgressBar, и покажите данные в RecyclerView.

1 Ответ

0 голосов
/ 04 февраля 2019

Вы можете использовать два макета в качестве дочернего элемента основного макета.Первый макет содержит TextView и ProgressBar, а его видимость установлена ​​на visible.

Второй макет - это FirestoreRecyclerView, для которого установлено значение invisible или gone.

Как только ваш код получит данные для этого 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);
...