Paste_Image.png
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@id/rootView"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/view_progress"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_gravity="center"
android:orientation="vertical"
android:visibility="gone">
<ProgressBar
android:id="@+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/text_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/loading"/>
</LinearLayout>
<FrameLayout
android:id="@+id/view_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</FrameLayout>
<LinearLayout
android:id="@+id/view_empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:visibility="gone">
<TextView
android:id="@+id/text_tip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/empty_data"/>
</LinearLayout>
</FrameLayout>
public void showView(int viewId) {
for (int i = 0; i < rootView.getChildCount(); i++) {
if (viewId == rootView.getChildAt(i).getId()) {
rootView.getChildAt(i).setVisibility(View.VISIBLE);
} else {
rootView.getChildAt(i).setVisibility(View.GONE);
}
}
}
public void showProgressView() {
showView(R.id.view_progress);
}
public void showContentView() {
showView(R.id.view_content);
}
public void showEmptyView() {
showView(R.id.view_empty);
}
网友评论