I have a asynchtask for some database operation
Before I start the task I call this function, to show a prograssBar
The ProgressBar is in a RelativLayout because someone on the net says that calling setVisibility();
on the progressBar doesn´t work in some chases (and it doesn´t for me either)
public static void showProgressBar()
{
Log.e("TEST","Try to show ProgressBar, Visibiliy: " + prog_bar.getVisibility());
if(prog_bar != null)
{
prog_bar.setVisibility(RelativeLayout.VISIBLE);
Log.e("TEST","Success");
}
else
{
Log.e("TEST","prog_bar != null");
}
Log.e("TEST","Visibiliy: " + prog_bar.getVisibility());
}
on PostExecute i call the function:
public static void hideProgressBar()
{
Log.e("TEST","Try to hide ProgressBar, Visibiliy: " + prog_bar.getVisibility());
if(prog_bar != null)
{
prog_bar.setVisibility(RelativeLayout.INVISIBLE);
Log.e("TEST","Success");
}
else
{
Log.e("TEST","prog_bar != null");
}
Log.e("TEST","Visibiliy: " + prog_bar.getVisibility());
}
Strange thing is that the methods are called correct, also the Logs are correct and no error appears, but no progressBar shows up.
Android 2.2, Windows 7, Tested on Emulator and GalaxyTab
Best regards schwandi
EDIT:
Changed my methods to:
public static void hideProgressBar()
{
if(prog_bar != null)
{
Log.e("TEST","Try to hide ProgressBar, Visibiliy: " + prog_bar.getVisibility());
prog_bar.setVisibility(View.GONE);
Log.e("TEST","Success");
}
else
{
Log.e("TEST","prog_bar != null");
}
Log.e("TEST","Visibiliy: " + prog_bar.getVisibility());
}
public static void showProgressBar()
{
if(prog_bar != null)
{
Log.e("TEST","Try to show ProgressBar, Visibiliy: " + prog_bar.getVisibility());
prog_bar.setVisibility(View.VISIBLE);
Log.e("TEST","Success");
}
else
{
Log.e("TEST","prog_bar != null");
}
Log.e("TEST","Visibiliy: " + prog_bar.getVisibility());
}
still doens´t work.
Also i changed that prog_bar is the ProgressBar itself.
prog_bar = (ProgressBar) findViewById(R.id.progressBar1);