我正在从 Firebase Firestore 获取数据来填充 ListView,并且我想在获取数据时显示加载动画。
最佳答案
布局代码
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout android:id="@+id/loading"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
xmlns:android="http://schemas.android.com/apk/res/android">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true" />
</RelativeLayout>
<ListView android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
xmlns:android="http://schemas.android.com/apk/res/android" />
</FrameLayout>
java代码
private void finishLoadList(){
RelativeLayout loadingLayout = (RelativeLayout) findViewById(R.id.loading);
ListView listView = (ListView) findViewById(R.id.list_view);
loadingLayout.setVisibility(View.GONE);
listView.setVisibility(View.VISIBLE);
}
关于java - 从 Firestore 获取数据时 Android 加载图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47523532/