In a function handling a registration form I want to set the visibility of button to invisible and the visibility of a progress bar to visible. The problem now is, that the following code which handles some OAuth requests seems to prevent the widgets to show their visibility exactly where I want them to.
Setting the visibility of the progressbar stops (is frozen?) until the oauth requests are finished. How can I fix that?! I think working with sleep()s, wait()s or timers would be a bad solution here…
private void registerOnce(){
ProgressBar spinner = (ProgressBar) findViewById(R.id.progressBar);
Button login = (Button) findViewById(R.id.buttonLogin);
spinner.setVisibility(View.VISIBLE);
login.setVisibility(View.INVISIBLE);
// Here goes the code for some oauth requests
// This code here seems to prevent setting the
// the visibility where I want it to.
spinner.setVisibility(View.INVISIBLE);
login.setVisibility(View.VISIBLE);
}
Better to Use AsyncTask
in
onPreExecute()in
doInBackgroundAnd in
onPostExecute