我有一个应该在的AsyncTask运行进度,但它没有出现,虽然任务运行Android的进度条不显示
XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:background="@drawable/splashportrait">
<ProgressBar android:layout_alignParentBottom="true" android:indeterminate="true"
android:layout_centerHorizontal="true" android:paddingBottom="450dip"
android:layout_width="200dip" android:layout_height="200dip"
android:id="@+id/progressBar1"></ProgressBar>
</RelativeLayout>
CODE:
ProgressBar diagProgress;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splashscreen);
diagProgress = (ProgressBar)findViewById(R.id.progressBar1);
DiagnosticsTask diag = new DiagnosticsTask();
diag.execute();
/**rest of class ommitted here**/
}
private class DiagnosticsTask extends AsyncTask<String, String, Boolean> {
//Show spinner
protected void onPreExecute() {
//dialog.setMessage("Loading corresponding destinations...");
//dialog.show();
diagProgress.setVisibility(View.VISIBLE);
diagProgress.showContextMenu();
Log.e("AsyncStatus", "spinner shown");
}
/*other parts of the thread ommitted here*/
}
嘿你问题解决了吗? – shyam