progressdialog - How to display progress dialog before starting an activity in Android? -


how display progress dialog before starting activity (i.e., while activity loading data) in android?

you should load data in asynctask , update interface when data finishes loading.

you start new activity in asynctask's onpostexecute() method.

more specifically, need new class extends asynctask:

public class mytask extends asynctask<void, void, void> {   public mytask(progressdialog progress) {     this.progress = progress;   }    public void onpreexecute() {     progress.show();   }    public void doinbackground(void... unused) {     ... loading here ...   }    public void onpostexecute(void unused) {     progress.dismiss();   } } 

then in activity do:

progressdialog progress = new progressdialog(this); progress.setmessage("loading..."); new mytask(progress).execute(); 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -