在显示包含gridlayout的.xml文件之前,是否有解决方案可以显示进度条(循环)?我试图在其他问题中找到它,但没有找到类似的东西。谢谢!
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="ScrollViewCount">
<GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:rowCount="19"
android:columnCount="2">
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:id="@+id/teacher1"
android:focusable="true"
android:layout_gravity="fill_horizontal"
android:layout_row="0"
android:layout_column="0">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:padding="2dp"
android:src="@drawable/woman"
android:contentDescription="@string/woman" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="@string/phdr_ludmila_b_l_kov"
android:textStyle="bold"
android:fontFamily="@font/josefin"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/kabinet_105_kolka"
tools:ignore="RtlHardcoded,RtlSymmetry"
android:fontFamily="@font/caviar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/vyu_ovan_p_edm_ty"
android:textColor="@color/colorAccent"
android:layout_margin="10dp"
android:fontFamily="@font/caviar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="@string/ludmila_belikova_oavm_cz"
android:fontFamily="@font/caviar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="@string/_420_571_755_504"
android:drawableStart="@drawable/ic_phone_black_24dp"
tools:ignore="RtlHardcoded,RtlSymmetry"
android:fontFamily="@font/caviar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/konzulta_n_hodiny"
android:layout_marginTop="5dp"
android:fontFamily="@font/josefin"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pond_l_7_00_7_30"
tools:ignore="RtlHardcoded"
android:layout_margin="3dp"
android:fontFamily="@font/caviar"
android:drawableStart="@drawable/ic_access_time_black_24dp"/>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:id="@+id/teacher2"
android:focusable="true"
android:layout_gravity="fill_horizontal"
android:layout_row="0"
android:layout_column="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:padding="2dp"
android:src="@drawable/woman"
android:contentDescription="@string/woman" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="@string/mgr_jana_blinkov"
android:textStyle="bold"
android:fontFamily="@font/josefin"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/kabinet_151_kolka"
tools:ignore="RtlHardcoded,RtlSymmetry"
android:fontFamily="@font/caviar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/vyu_ovan_p_edm_ty"
android:textColor="@color/colorAccent"
android:layout_margin="10dp"
android:fontFamily="@font/caviar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="@string/jana_blinkova_oavm_cz"
android:fontFamily="@font/caviar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="@string/_420_571_755_526"
android:drawableStart="@drawable/ic_phone_black_24dp"
tools:ignore="RtlHardcoded,RtlSymmetry"
android:fontFamily="@font/caviar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/konzulta_n_hodiny"
android:layout_marginTop="5dp"
android:fontFamily="@font/josefin"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tvrtek_7_00_7_30"
android:layout_margin="3dp"
tools:ignore="RtlHardcoded"
android:fontFamily="@font/caviar"
android:drawableStart="@drawable/ic_access_time_black_24dp"/>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:id="@+id/teacher3"
android:focusable="true"
android:layout_row="1"
android:layout_column="0">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:padding="2dp"
android:src="@drawable/woman"
android:contentDescription="@string/woman" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="@string/rndr_eva_tver_kov"
android:textStyle="bold"
android:fontFamily="@font/josefin"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/kabinet_243_hlavn_budova"
tools:ignore="RtlHardcoded,RtlSymmetry"
android:fontFamily="@font/caviar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/vyu_ovan_p_edm_ty"
android:textColor="@color/colorAccent"
android:layout_margin="10dp"
android:fontFamily="@font/caviar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="@string/eva_ctverackova_oavm_cz"
android:fontFamily="@font/caviar"
android:clickable="true"
android:inputType="textEmailAddress"
android:focusable="true"
tools:ignore="TextViewEdits" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="@string/_420_571_755_513"
android:drawableStart="@drawable/ic_phone_black_24dp"
tools:ignore="RtlHardcoded,RtlSymmetry"
android:fontFamily="@font/caviar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/konzulta_n_hodiny"
android:layout_marginTop="5dp"
android:fontFamily="@font/josefin"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pond_l_15_15_16_00"
android:layout_margin="3dp"
tools:ignore="RtlHardcoded"
android:fontFamily="@font/caviar"
android:drawableStart="@drawable/ic_access_time_black_24dp"/>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:id="@+id/teacher4"
android:focusable="true"
android:layout_row="1"
android:layout_column="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:padding="2dp"
android:src="@drawable/woman"
android:contentDescription="@string/woman" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="@string/mgr_jitka_g_brl_kov"
android:textStyle="bold"
android:fontFamily="@font/josefin"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/kabinet_255_hlavn_budova"
tools:ignore="RtlHardcoded,RtlSymmetry"
android:fontFamily="@font/caviar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/vyu_ovan_p_edm_ty"
android:textColor="@color/colorAccent"
android:layout_margin="10dp"
android:fontFamily="@font/caviar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="@string/jitka_gabrlikova_oavm_cz"
android:fontFamily="@font/caviar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="@string/_420_571_755_515"
android:drawableStart="@drawable/ic_phone_black_24dp"
tools:ignore="RtlHardcoded,RtlSymmetry"
android:fontFamily="@font/caviar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/konzulta_n_hodiny"
android:layout_marginTop="5dp"
android:fontFamily="@font/josefin"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/st_eda_7_00_7_30"
android:layout_margin="3dp"
tools:ignore="RtlHardcoded"
android:fontFamily="@font/caviar"
android:drawableStart="@drawable/ic_access_time_black_24dp"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</GridLayout>
</ScrollView>
FirstFragment.java
package com.app.clupascu.oavm;
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.CardView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ImageButton;
import java.util.Objects;
public class FirstFragment extends Fragment {
private CardView teacher1;
private CardView teacher2;
private CardView teacher3;
private CardView teacher4;
@SuppressLint("SetJavaScriptEnabled")
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View vw = inflater.inflate(R.layout.fragment_first, container, false);
teacher1 = (CardView) vw.findViewById(R.id.teacher1);
teacher2 = (CardView) vw.findViewById(R.id.teacher2);
teacher3 = (CardView) vw.findViewById(R.id.teacher3);
teacher4 = (CardView) vw.findViewById(R.id.teacher4);
teacher1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Dialog dialog = new Dialog(Objects.requireNonNull(getContext()));
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.ludmila_belikova);
ImageButton dialogButton = (ImageButton)dialog.findViewById(R.id.clButton);
dialogButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
});
teacher2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Dialog dialog = new Dialog(Objects.requireNonNull(getContext()));
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.jana_blinkova);
ImageButton dialogButton = (ImageButton)dialog.findViewById(R.id.clButton);
dialogButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
});
teacher3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Dialog dialog = new Dialog(Objects.requireNonNull(getContext()));
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.eva_ctverackova);
ImageButton dialogButton = (ImageButton)dialog.findViewById(R.id.clButton);
dialogButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
});
teacher4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Dialog dialog = new Dialog(Objects.requireNonNull(getContext()));
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.jitka_garlikova);
ImageButton dialogButton = (ImageButton)dialog.findViewById(R.id.clButton);
dialogButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
});
return vw;
}
}
编辑,我添加了.xml和.java文件。 因此,我有4个CardView,如果可能的话,我希望显示进度条(循环),直到显示出包含gridlayout的.xml文件为止。
答案 0 :(得分:1)
您必须在xml文件中创建进度栏。
<ProgressBar
android:id="@+id/progressbar"
style="?android:attr/progressBarStyleLarge"
android:visibility="visible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>
在活动或片段中使用 setVisibility 。
progressBar.setVisibility(View.VISIBLE);
之后,您应该调用gridView方法。
然后setVisibility消失了。这样。
progressBar.setVisibility(View.GONE);
进度条可见,直到显示网格布局。