我想显示进度条,而折线将在屏幕上绘制。我知道Polyline只在UI线程中绘制。我试过nextcode,但这没有用。没有进度对话框
final Handler mHandler = new Handler();
class shpLoading extends AsyncTask<Void, Void, Void> {
ProgressDialog dialog;
@Override
protected Void doInBackground(Void... params) {
mHandler.post(new Runnable() {
public void run() {
googleMap.addPolyline(new PolylineOptions()
.addAll(mRoutePoints)
.width(3)
.color(Color.RED));
}
});
return null;
}
@Override
protected void onPreExecute() {
Log.d("myLogs", "onPreExecute");
dialog = new ProgressDialog(getActivity());
dialog.setMessage("Kraunama...");
dialog.setIndeterminate(true);
dialog.setCancelable(false);
dialog.show();
}
@Override
protected void onPostExecute(Void result) {
Log.d("myLogs", "onPostExecute");
dialog.dismiss();
}
}
shpLoading shpLoading = new shpLoading();
shpLoading.execute();