Question

I've seen this in lots of app , they don't use ProgressDialog because it doesn't let us to do anything in the app.I don't want that . I've seen it in another app ,instead of ProgressDialog , they make the ui to show a progressbar and also we can do other work either, for example the whole ui become a progressbar and when it's done, the main ui loads . I think they use another layout when progress is activated and when it's done , the bring back the main layout . I made a layout like this :

<?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>

I was wondering how could I do that?

thanks so much.

Was it helpful?

Solution

There are many ways you can achieve this. I saw you one way.

You can make a Custom Dialog and load this layout using Inflater and set layout to your Dialog. like

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();

and when your progress is completed you dismiss this dialog using main_dialog.dismiss();

also in this layout you can display progress text and progress by using some TextView.

Output:

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top