Show a progress dialog in android tab layout?

Well each tab is an activity... I suppose that what is taking time is in the settings activity Put this in the setting activity: public void onCreate(Bundle savedInstanceState) { super. OnCreate(savedInstanceState); final ProgressDialog dialog = ProgressDialog. Show(getParent(), "Please wait..", "Doing stuff..", true); dialog.

SetCancelable(false); dialog.show(); Runnable myRun = new Runnable(){ public void run(){ Looper.myLooper().prepare(); //DO EVERYTHING YOU WANT! //Finally runOnUiThread(new Runnable() { @Override public void run() { dialog.dismis(); } }); } }; Thread T = new Thread(myRun); T.start() Remember : In you run() in this block DO EVERYTHING YOU WANT! If anything needs to change the UI, you must do it using runOnUiThread(new Runnable() { @Override public void run() { //DO IT } }).

Well each tab is an activity... I suppose that what is taking time is in the settings activity... Put this in the setting activity: public void onCreate(Bundle savedInstanceState) { super. OnCreate(savedInstanceState); final ProgressDialog dialog = ProgressDialog. Show(getParent(), "Please wait..", "Doing stuff..", true); dialog.

SetCancelable(false); dialog.show(); Runnable myRun = new Runnable(){ public void run(){ Looper.myLooper().prepare(); //DO EVERYTHING YOU WANT! //Finally runOnUiThread(new Runnable() { @Override public void run() { dialog.dismis(); } }); } }; Thread T = new Thread(myRun); T.start(); Remember: In you run() in this block //DO EVERYTHING YOU WANT! If anything needs to change the UI, you must do it using runOnUiThread(new Runnable() { @Override public void run() { //DO IT } }).

I have tried it on Settings tab, After but I need to show the progress dialog before the settings layout is displayed. Here when I click the settings tab, there is delay for showing the layout, the progress dailog is give in the settings activity context,..but I need to show it inside the tabactivity context – jennifer Aug 2 at 12:19 Do you think the work that is taking time is in the onDestroy of the previous tab? Or is it in the onCreate of the settings tab?

– Sherif Aug 2 at 12:26 Runnable myRun = new Runnable(){ public void run(){ //DO EVERYTHING YOU WANT! Is not calling – jennifer Aug 2 at 13:21 I have a method inside the run method, but its not calling – jennifer Aug 2 at 13:21 oh sorry @jennifer I edited the answer :$ I added Thread T = new Thread(myRun); T.start(); – Sherif Aug 2 at 13:28.

You can use the asyntask feature of android to show Progress dialog refer this developer.android.com/reference/android/....

Wher I will start this Async task – jennifer Aug 2 at 12:20 on create itself, then load your layout in doinbackground() method of asyntask & on postExecute remove your Progress – hotveryspicy Aug 2 at 12:25.

Refer to my answer here, "Rotating wheel" progress dialog while deleting folder from SD card or you must go for async task to do this.

I need to show the progress dialog before the settings layout is displayed. Here when I click the settings tab, there is delay for showing the layout, the progress dailog is give in the settings activity context,..but I need to show it inside the tabactivity context – jennifer Aug 2 at 12:19 Try modifying it accordingly. Try calling progressdialog.

Show before setContent to your activity. But this has to be done as I have done it. Use separate thread.

– Andro Selva Aug 2 at 12:32 I tries like that, an exception is thrown when I tried to close the dialog inside that handler – jennifer Aug 2 at 13:23 What error are you getting – Andro Selva Aug 2 at 13:25 08-02 19:06:34.068: ERROR/AndroidRuntime(32315): java.lang. RuntimeException: Can't create handler inside thread that has not called Looper.prepare() 08-02 19:06:34.068: ERROR/AndroidRuntime(32315): at android.os.Handler.(Handler. Java:121) – jennifer Aug 2 at 13:39.

If getParent() doesn't work for you, try using just TabsActivity. Context (or substitute the name of your parent tab activity class). I am using nested activities and as a result using getParent() is still not returning the right context for the dialog.

And it worked like a charm. You'll also need to create the context variable in the TabsActivity class. Something like public static TabsActivity context; and context=this in the onCreate method.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions