Can anyone tell me why progress bar wheel is not rotating … I am trying to put a progress bar while downloading data from web server everything is fine till now…i am able to set the progress bar while downloading data but the problem progress bar spinner is not rotating….Below is my code for progress bar:
<Progressbar
android:id="@+id/xPBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
style="@android:style/Widget.ProgressBar.Inverse"/>
this is the downloading code:
while executing this method i am showing the progress bar
public void downloadAlerts() {
mPBar.setVisibility(ProgressBar.VISIBLE);
Runnable r = new Runnable() {
@Override
public void run() {
if (checkNetworkStatus(getApplicationContext()) == true) {
String alert = con.execute(ALERTS_URL
);
AlertsParser parser = new AlertsParser();
parser.parseJson(alert);
startActivity(new Intent(getApplicationContext(), Alerts.class));
onSuccessDownload();
} else if (checkNetworkStatus(getApplicationContext()) == false) {
onFailureDownload();
}
}
};
mHandler.post(r);
}
Thanks…
You likely have to put it into an AsyncTask. If you try to put the progress bar in your main UI thread then it won’t move if you do something else in the background as explained here.