I have a tablayout with several activities in it, and changing from a tab to another one takes a couple of seconds (because it needs lots of datas). While it is loading I want a dialog appear that indicates the loading. I created a very simple dialog with a progress bar, but I dont know when to call it and when to dismiss it.
loading = new Dialog(FatActivity.this);
loading.requestWindowFeature(Window.FEATURE_NO_TITLE);
loading.setContentView(R.layout.dialog_loading);
loading.show();
Every tab shows an activity, but if I put it in the onCreate() method (right after it, so to the first row), it doesnt appear, only after the activity loaded. So where should I put it, or if it is a wrong approach of making a loading screen then how should I do this? I was thinking about this, because I just have to call it then dismiss it at the end of the onCreate(). And since it is a tablayout there is no onclicklistener on the tabs, so I cannot use it either.
Thanks in advance!
You can use AsyncTask best way to display Loading screen…