【发布时间】:2012-07-24 09:17:55
【问题描述】:
我创建了一个 AsyncTask 类用于从后台获取数据(访问数据库)。
在onPreExecute()方法中,我创建了一个进度对话框
try {
progressDialog = ProgressDialog.show(context, "",
"Please wait...", true);
progressDialog.setIndeterminate(true);
} catch (final Throwable th) {
// TODO
}
在 onpostExecute() 中
protected void onPostExecute(Boolean result) {
pinPoint();
progressDialog.dismiss();
}
我更新的课程,
@Override
protected Boolean doInBackground(Void... params) {
clust = getPinPointClusters();
runOnUiThread(new Runnable() {
public void run() {
plotClusters(clust);
}
});
return true;
}
@Override
protected void onPostExecute(Boolean result) {
progressDialog.dismiss();
}
这里的 pinpoint() 方法将从服务器获取一些数据并将点固定在地图中。 但是 ProgressDialog 中的 progressBar 没有动画...... 请给我最好的方法...
谢谢
【问题讨论】:
-
doInBackGround()中我没有使用pinPoint(),因为这个方法会影响UI
-
getPinPointClusters() 方法是否尝试更新 UI??
-
@Haresh Chaudhary,不,它只会返回 GeoCluster 对象
-
@Haresh Chaudhary,但是 plotCluster() 会更新 UI
-
试试这个方法..改变这个 runOnUiThread(new Runnable() {...to activityname.runOnUiThread(new Runnable()...