This is what I am doing
ProgressBar myProgressBar = (ProgressBar) findViewById(R.id.progressBar);
myProgressBar.setVisibility(View.VISIBLE);
fetchData();
mainView();
myProgressBar.setVisibility(View.INVISIBLE);
But the progressbar does not show.
fetchData takes around 5 seconds and while it is running, the progressbar should be shown.
I guess the display is not updated while the App is busy. Is there a way to update the display before I call fetchData?
You should try using an AsyncTask. This will allow you to run
fetchData()using thedoInBackground(...)method and post progress usingonProgressUpdate(...).