-4
我在android mainactivity中有一個進度條。Android進度條沒有顯示出來
<ProgressBar
android:id="@+id/progress_bar"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@android:style/Widget.ProgressBar.Large"
android:layout_marginRight="5dp" />
public class MainPage extends FragmentActivity
{
public ProgressBar mProgress;
protected void onCreate(Bundle savedInstanceState)
{
mProgress = (ProgressBar) findViewById(R.id.progress_bar);
//setting onbuttonclick call refreshInfo()
}
public void refreshInfo()
{
GetInfo myTask = new GetInfo(this);
myTask.execute(excute);
}
}
public class GetInfo extends AsyncTask class
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
activity.mProgress.setVisibility(View.INVISIBLE);
super.onPreExecute();
}
@Override
protected void onPostExecute(BusLocations result) {
// TODO Auto-generated method stub
activity.callMainThreadFuctionToDoStuff
activity.mProgress.setVisibility(View.VISIBLE);
super.onPostExecute(result);
}
一切工作正常,除了進度條永遠不會顯示。只是爲了確保它不是很快,我在doInBackground中添加了10秒的延遲。
你介意延長你的答案嗎? – bummi