Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android-如何使用另一个布局作为progressbar_Android_Progressdialog_Android Progressbar - Fatal编程技术网

Android-如何使用另一个布局作为progressbar

Android-如何使用另一个布局作为progressbar,android,progressdialog,android-progressbar,Android,Progressdialog,Android Progressbar,我在很多应用程序中都见过这种情况,他们不使用ProgressDialog,因为它不允许我们在应用程序中做任何事情。我不希望这样。 我在另一个应用程序中看到了它,而不是ProgressDialog,它们使ui显示一个progressbar,我们也可以做其他工作,例如整个ui变成一个progressbar,完成后,主ui加载。我认为,当进度被激活时,他们会使用另一个布局,当进度完成时,会返回主布局。 我做了一个这样的布局: <?xml version="1.0" encoding="utf-8

我在很多应用程序中都见过这种情况,他们不使用
ProgressDialog
,因为它不允许我们在应用程序中做任何事情。我不希望这样。 我在另一个应用程序中看到了它,而不是
ProgressDialog
,它们使ui显示一个progressbar,我们也可以做其他工作,例如整个ui变成一个progressbar,完成后,主ui加载。我认为,当进度被激活时,他们会使用另一个布局,当进度完成时,会返回主布局。 我做了一个这样的布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true" >
    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="79dp"
        android:src="@drawable/load_more" />
   <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/loading"
        android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>

我在想我怎么能这么做


非常感谢。

有很多方法可以实现这一点。我从一个角度看到了你

您可以创建一个
自定义对话框
,使用
充气机加载此布局
,并将布局设置为您的
对话框
。像

LayoutInflater factory = LayoutInflater.from(Activity.this);
View DialogView = factory.inflate(R.layout.custom_progress_layout, null);

Dialog main_dialog = new Dialog(Activity.this,R.style.Theme_Dialog);
main_dialog.setContentView(DialogView);

progressBar=(ProgressBar)DialogView.findViewById(R.id.progressBar1);
main_dialog.setCancelable(false);
main_dialog.setCanceledOnTouchOutside(false);
progressBar.setProgress(0);
progressBar.setMax(100);
main_dialog.show();
当您的进度完成时,您可以使用
main_dialog.disease()关闭该对话框

此外,在此布局中,您还可以使用一些
TextView
显示进度文本和进度

输出:


谢谢你的回复,我照你说的做了,但这仍然是一个对话。我的意思是,它会打开一个对话框,但我不想让它成为一个对话框,我想让用户界面获得进度条,然后消失。@user3579994我告诉过你的。有很多方法。尝试此操作,或者您可以将此
布局
作为单独的
活动